Week 7: Indexed Polygon and Simple Polygonal Modeling

·         Please download and unzip the Week7.zip file in the Files/WeeklyExamples folder.

 

1.       Quad and Index Polygons

a.       User our own shader: to avoid backface culling

b.      Triangles: Check out the simple details!

c.       Observation: Mesh is defined by [Fancy name: Indexed Polygon]

                                                               i.      An array of vertices

                                                             ii.      Triangle as indexed of vertices

d.      Note: completely BLACK! Why?

 

2.       Triangle with shading/illumination

a.       Only modification from above, included a “normal”!

b.      Normal:

                                                               i.      What are these

                                                             ii.      Notice they are defined on the Vertices

1.       Compare to real world, they should be defined on the face

c.       Observation:

                                                               i.      Not black triangle any more

1.       Adjust the light color to see the color respect the light that shines on it!

                                                             ii.      Mesh: have “optional” data

1.       We see “Normal” here

2.       There is UV, Color, … many

3.       Simple 2x2 Mesh (indexed)

a.       Here is the design.

b.      Note: consistency is important

                                                               i.      Should develop loop to do this

                                                             ii.      Must follow strict pattern (otherwise, difficult to develop the loop)

c.       NxN vertices:

                                                               i.      (N-1) x (N-1) x 2: number of triangles

                                                             ii.      NumTriangle x 3: number of triangle indices

d.      Number of normal vectors IS ALWAYS the same as number of vertices

 

4.       Manipulating Vertices

a.       Put primitives there to allow manipulation (in the editor)

b.      MyMesh_Manipulate.cs

                                                               i.      An array of spheres, corresponds to the array of vertices

                                                             ii.      Parent by MyMesh (will scale/move with MyMesh)

                                                            iii.      Update(), sets vertex positions using the corresponding spheres!

c.       J Simple?

d.      Note:

                                                               i.      Cannot tell what is going on!

                                                             ii.      Once giant piece of flat

 

5.       Surface Normal Vectors

a.       New file: MyMesh_NormalSupport

                                                               i.      InitNormals():

1.       Allocate line setments! J

                                                             ii.      UpdateNormals()

1.       Set line segments to be at vertex positions

2.       Second point in the corresponding normal direction

                                                            iii.      ComputeNormal()

1.       Computes triangle face normal.

2.       Average a vertex’s normal based on all connecting triangles!

b.      MyMesh:

                                                               i.      Init() è calls InitNormals()

                                                             ii.      Update() è calls ComputeNormal()

c.       Cool?

d.      Can you generalize all the functions to simple loops?

 

ð  Do we know how to draw a circle?

ð  Can we define a subclass of MyMesh to define a triangular cylinder?