- We want to separate geometry from topology
- Mesh:
→ collection of polygons (triangels often) which describe an object. The faces are arranged in such a way that they form the outside surface of the object
→ We're just going to deal with the outer shell of an object
→ example has 8 vertices, 12 edges and 5 polygons
→ each vertex has a location x,y,z
- Representing them:
→ the simple (bad) way that we've already done is hardcoding them
⇒ listing all polygons by their geometric locations
→ a good idea is to use data structures to separate geometry form topology
• geometry: locations of vertices
• topology: organization of the vertices, which ones are connected to others
• topology holds even if geometry changes.
⇒ Vertex lists:
• put the geometry into an array and use pointers from the vertices into this array
• define polygons as sets of indices into that array

Example: modeling a cube
- define a global array for vertices and colours
-
GLfloat vertices[][3] = {{,,},{,,}.... 8 of them
GLfloat colors[][3] = same thing

void polygon(int a, int b, int c, int d){
    glBegin(GL_POLYGON);
        glColor3fv(colors[a])
        glVertex3fv(vertices[b])
        ...
        
}

//call polygon 4 times to draw 4 faces of the cube


Normals


every plane has a vector normal (perpendicular) to it
we can use the cross product to find n

Normals of polygons:
- lets look at one polygon
- how to we tell openGL which way is up?
- it depends on the order we provide the vertices
- rule of thumb, curl ur hand in the direction you list the vertices to determine which way the normal points (follow ur thumb)

A2
- translate a planet out some distance from the origin
- scale it to the right size
- rotate it by some angle theta
- planet location (cos(theta), 0, sin(theta))

- corona: draw lines of a certain thickness starting just inside the sun.
→ colorSun = Rs Gs Bs
→ vertex of the base of the line is same as sun
→ outer vertex is more orange and more transparent
→ only on xy plane
→ more than one pixel thick

- read in the text file to draw the enterprise
- vertices come first, then faces
- draw it like we did the coloured cube
- just draw one triangle at a time in a for loop
- if the enterprise looks kinda fucky, probably off by 1 on the index into the vertex array. either + or - one
- increase the colour for every triangle
- camera is tied to the back of the enterprise

Index