The Mesh Class. Lecture 23. Robb T. Koether. Hampden-Sydney College. Wed, Oct 18, 2017

Similar documents
The Mesh Class. Lecture 26. Robb T. Koether. Wed, Oct 28, Hampden-Sydney College

Specular Reflection. Lecture 19. Robb T. Koether. Hampden-Sydney College. Wed, Oct 4, 2017

Applying Textures. Lecture 27. Robb T. Koether. Hampden-Sydney College. Fri, Nov 3, 2017

The Critical-Path Algorithm

Ambient and Diffuse Light

The string Class. Lecture 21 Sections 2.9, 3.9, Robb T. Koether. Wed, Oct 17, Hampden-Sydney College

The Projection Matrix

Minimal Spanning Trees

The Projection Matrix

while Loops Lecture 13 Sections Robb T. Koether Wed, Sep 26, 2018 Hampden-Sydney College

Recursive Sequences. Lecture 24 Section 5.6. Robb T. Koether. Hampden-Sydney College. Wed, Feb 27, 2013

Rotations and Translations

Recursive Sequences. Lecture 24 Section 5.6. Robb T. Koether. Hampden-Sydney College. Wed, Feb 26, 2014

Scope and Parameter Passing

The Graphics Pipeline

Implementing Linked Lists

Stack Applications. Lecture 27 Sections Robb T. Koether. Hampden-Sydney College. Wed, Mar 29, 2017

Scope and Parameter Passing

Street-Routing Problems

The Decreasing-Time Algorithm

LR Parsing - Conflicts

Boolean Expressions. Lecture 31 Sections 6.6, 6.7. Robb T. Koether. Hampden-Sydney College. Wed, Apr 8, 2015

Solving Recursive Sequences by Iteration

The Class Construct Part 1

Recursive Descent Parsers

The Graphics Pipeline

Abstract Data Types. Lecture 23 Section 7.1. Robb T. Koether. Hampden-Sydney College. Wed, Oct 24, 2012

Pointers. Lecture 1 Sections Robb T. Koether. Hampden-Sydney College. Wed, Jan 14, 2015

Sampling Distribution Examples Sections 15.4, 15.5

The Traveling Salesman Problem Brute Force Method

Introduction to Compiler Design

Density Curves Sections

Programming Languages

Building the Abstract Syntax Trees

Programming Languages

Nondeterministic Programming in C++

XPath Lecture 34. Robb T. Koether. Hampden-Sydney College. Wed, Apr 11, 2012

Binary Tree Applications

Stacks and their Applications

The Class Construct Part 2

The Coefficient of Determination

The Model Stack. Lecture 8. Robb T. Koether. Hampden-Sydney College. Wed, Sep 6, 2017

The Traveling Salesman Problem Nearest-Neighbor Algorithm

Shader Programs. Lecture 30 Subsections 2.8.2, Robb T. Koether. Hampden-Sydney College. Wed, Nov 16, 2011

Pointer Arithmetic. Lecture 4 Chapter 10. Robb T. Koether. Hampden-Sydney College. Wed, Jan 25, 2017

XPath. Lecture 36. Robb T. Koether. Wed, Apr 16, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) XPath Wed, Apr 16, / 28

Scheduling and Digraphs

Binary Tree Implementation

The Pairwise-Comparison Method

Binary Tree Implementation

Function Definition Syntax Tree

Boxplots. Lecture 17 Section Robb T. Koether. Hampden-Sydney College. Wed, Feb 10, 2010

Linked Lists. Lecture 16 Sections Robb T. Koether. Hampden-Sydney College. Wed, Feb 22, 2017

List Iterators. Lecture 27 Section Robb T. Koether. Hampden-Sydney College. Wed, Apr 8, 2015

Function Usage. Lecture 15 Sections 6.3, 6.4. Robb T. Koether. Hampden-Sydney College. Mon, Oct 1, 2018

Recognition of Tokens

The Constructors. Lecture 7 Sections Robb T. Koether. Hampden-Sydney College. Wed, Feb 1, 2017

The View Frustum. Lecture 9 Sections 2.6, 5.1, 5.2. Robb T. Koether. Hampden-Sydney College. Wed, Sep 14, 2011

List Iterators. Lecture 34 Section Robb T. Koether. Hampden-Sydney College. Wed, Apr 24, 2013

Displaying Distributions - Quantitative Variables

Total Orders. Lecture 41 Section 8.5. Robb T. Koether. Hampden-Sydney College. Mon, Apr 8, 2013

Shading Triangles. Lecture 37. Robb T. Koether. Hampden-Sydney College. Mon, Nov 30, 2015

Dynamic Allocation of Memory

Recursion. Lecture 2 Sections Robb T. Koether. Hampden-Sydney College. Wed, Jan 17, 2018

Recursive Linked Lists

Quadric Surfaces. Six basic types of quadric surfaces: ellipsoid. cone. elliptic paraboloid. hyperboloid of one sheet. hyperboloid of two sheets

Inheritance: The Fundamental Functions

MySQL Creating a Database Lecture 3

The CYK Parsing Algorithm

The Traveling Salesman Problem Cheapest-Link Algorithm

Magnification and Minification

LR Parsing - The Items

Array Lists. Lecture 15. Robb T. Koether. Hampden-Sydney College. Mon, Feb 22, 2016

JFlex Regular Expressions

XML Attributes. Lecture 33. Robb T. Koether. Hampden-Sydney College. Wed, Apr 25, 2018

Friends and Unary Operators

Regular Expressions. Lecture 10 Sections Robb T. Koether. Hampden-Sydney College. Wed, Sep 14, 2016

Inheritance: The Fundamental Functions

Webpage Navigation. Lecture 27. Robb T. Koether. Hampden-Sydney College. Mon, Apr 2, 2018

4 = 1 which is an ellipse of major axis 2 and minor axis 2. Try the plane z = y2

Array Lists. Lecture 15. Robb T. Koether. Hampden-Sydney College. Fri, Feb 16, 2018

Form Validation. Lecture 25. Robb T. Koether. Hampden-Sydney College. Wed, Mar 23, 2018

Dynamic Allocation of Memory

Stack Applications. Lecture 25 Sections Robb T. Koether. Hampden-Sydney College. Mon, Mar 30, 2015

The Plurality-with-Elimination Method

The Standard Template Library Classes

Mipmaps. Lecture 35. Robb T. Koether. Hampden-Sydney College. Wed, Nov 18, 2015

Pointers. Lecture 2 Sections Robb T. Koether. Hampden-Sydney College. Fri, Jan 18, 2013

Aggregation. Lecture 7 Section Robb T. Koether. Hampden-Sydney College. Wed, Jan 29, 2014

DTDs and XML Attributes

CS 432 Interactive Computer Graphics

XQuery FLOWR Expressions Lecture 35

Operators. Lecture 12 Section Robb T. Koether. Hampden-Sydney College. Fri, Feb 9, 2018

Pointers. Lecture 2 Sections Robb T. Koether. Hampden-Sydney College. Mon, Jan 20, 2014

PHP Queries and HTML Forms Lecture 23

Fundamental Data Types

List Iterator Implementation

Integer Overflow. Lecture 8 Section 2.5. Robb T. Koether. Hampden-Sydney College. Mon, Jan 27, 2014

The Normal Distribution

Recursion. Lecture 26 Sections , Robb T. Koether. Hampden-Sydney College. Mon, Apr 6, 2015

Transcription:

The Mesh Class Lecture 23 Robb T. Koether Hampden-Sydney College Wed, Oct 18, 2017 Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 1 / 21

Outline 1 The Mesh Class 2 Assignment Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 2 / 21

Outline 1 The Mesh Class 2 Assignment Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 3 / 21

The Mesh Class The Mesh class will construct a mesh of any specified refinement for Squares Disks Spheres Cylinders Cones Paraboloids Hyperbolic paraboloids Hyperboloids of one sheet Toruses Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 4 / 21

The Constructors The Constructors Mesh(); The default constructor creates an empty mesh (no vertices). The copy constructor creates a copy of the specified mesh. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 5 / 21

The MeshType Enumerated Type The MeshType Enumerated Type enum MeshType {MESH_SQUARE, MESH_DISK, MESH_DISK_OUTSIDE, MESH_SPHERE, MESH_CYLINDER, MESH_CONE, MESH_PARABOLOID, MESH_HYPERBOLOID, MESH_HYPERBOLIC_PARABOLOID, MESH_TORUS}; The class uses the enumerated MeshType to specify the type of object. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 6 / 21

The Data Members The Data Members GLuint vbo; GLuint vao; GLint num_s; GLint num_t; vec3 m_amb; vec3 m_diff; vec3 m_spec; GLfloat m_shiny; // Vertex Buffer Object // Vertex Array Object // Number of subdivisions in s // Number of subdivisions in t // Material ambient property // Material diffuse property // Material specular property // Material shininess Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 7 / 21

The Parameterized Mesh Each mesh uses parameters s and t. The programmer specifies The type of object to create. The coarseness of the mesh (number of subintervals) in each of the s and t directions. The starting and ending values for each of s and t. The direction in which the normals are to point (inward or outward). Any other necessary parameters, such as a radius. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 8 / 21

The Parameterized Mesh The Mesh class contains functions for the parameteriration of each of the types of object specified above. To create a new type of object, the programmer would need to Parameterize the surface in s and t. Provide the formulas for the vertices. Provide the formulas for the normals. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 9 / 21

The create() Functions The First create() Function void create(meshtype type, int n_s, float start_s, float end_s, int n_t, float start_t, float end_t, bool dir = true); n_s number of cells in the s direction. start_s initial value of s. end_s final value of s. Similarly for t. dir direction of the normal. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 10 / 21

The create() Functions The Second create() Function void create(meshtype type, int n_s, float start_s, float end_s, int n_t, float start_t, float end_t, float rad, bool dir = true); rad a radius (for circles, paraboloids, etc.) Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 11 / 21

The create() Functions The Third create() Function void create(meshtype type, int n_s, float start_s, float end_s, int n_t, float start_t, float end_t, float rad1, float rad2, bool dir = true); rad1 first radius rad2 second radius A torus has two radii. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 12 / 21

Spheres Spheres Mesh sphere; sphere.create(mesh_sphere, 40, 0.0f, 2.0f*PI, 20, -0.5f*PI, 0.5f*PI); sphere.draw(); This will draw a sphere of radius 1.0. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 13 / 21

Spheres Spheres Mesh sphere; sphere.create(mesh_sphere, 40, 0.0f, 2.0f*PI, 20, -0.5f*PI, 0.5f*PI, 3.0f); sphere.draw(); This will draw a sphere of radius 3.0. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 14 / 21

Paraboloids Paraboloids Mesh paraboloid; paraboloid.create(mesh_paraboloid, 40, 0.0f, 2.0f*PI, 20, 0.0f, 3.0f); paraboloid.draw(); This will draw a standard paraboloid of height 3.0. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 15 / 21

Paraboloids Paraboloids Mesh paraboloid; paraboloid.create(mesh_paraboloid, 40, 0.0f, 2.0f*PI, 20, 0.0f, 3.0f, 1.0f); paraboloid.draw(); This will draw a paraboloid of height 3.0 and with a top radius of 1.0. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 16 / 21

Hyperboloids of One Sheet Hyperboloids of One Sheet Mesh hyperboloid; hyperboloid.create(mesh_hyperboloid, 40, 0.0f, 2.0f*PI, 20, -3.0f, 3.0f); hyperboloid.draw(); This will draw a standard hyperboloid of one sheet ranging from -3.0 to 3.0 vertically. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 17 / 21

Hyperboloids of One Sheet Hyperboloids of One Sheet Mesh hyperboloid; hyperboloid.create(mesh_hyperboloid, 40, 0.0f, 2.0f*PI, 20, -3.0f, 3.0f, 2.0f); hyperboloid.draw(); This will draw a hyperboloid of one sheet ranging from -3.0 to 3.0 vertically with a minimum radius of 2.0. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 18 / 21

Hyperboloids of One Sheet Hyperboloids of One Sheet Mesh hyperboloid; hyperboloid.create(mesh_hyperboloid, 40, 0.0f, 2.0f*PI, 20, -3.0f, 3.0f, 2.0f, 3.0f); hyperboloid.draw(); This will draw a hyperboloid of one sheet ranging from -3.0 to 3.0 vertically with a minimum radius of 2.0 and a top radius of 3.0. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 19 / 21

Other Member Functions Other Member Functions void clear(); void draw(bool fill = true); clear() Return the object to the empty state. draw() Draw the object. If fill is true, then the mesh is filled in (solid). If fill is false, then the mesh is rendered as a wire frame. The default value is true. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 20 / 21

Outline 1 The Mesh Class 2 Assignment Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 21 / 21

Assignment Assignment Read pp. 359-368, Classic Lighting Model. Robb T. Koether (Hampden-Sydney College) The Mesh Class Wed, Oct 18, 2017 22 / 21