See the presentation in the previous lecture
glMap2f(target, u_min, u_max, u_stride, u_order,
v_min, v_max, v_stride, v_order, point_array);
or
glMap2f(target, u_min, u_max,
v_min, v_max, point_array);
glEnable(type);
glEvalCoord2f(u,v);
The C-style call requires a stride and order in each dimension, and the control points array is entirely flattened. The Python call uses nested arrays, which is in some ways more intuitive, but requires thinking about which dimension to nest inside. It often doesn't matter, but if you're asking OpenGL to generate normal vectors, it does.
Note that the points are left to right, top to bottom, not counterclockwise!
The target is the sort of thing you want OpenGL to compute for you. Often, you want it to compute vertices in 3D, so you would specify
GL_MAP2_VERTEX_3
You might also want it to compute 2D texture coordinates, so you would specify
GL_MAP2_TEXTURE_COORD_2
See FlagPole.py for an example that uses both.
glMapGrid2f(u_steps,u_min,u_max,v_steps,v_min,v_max); glEvalMesh2(GL_FILL,u_start,u_stop,v_start,v_stop);
glMap2f(GL_MAP2_VERTEX_3, u_min, u_max,
v_min, v_max, point_array);
glEnable(GL_MAP2_VERTEX_3);
glMap2f(GL_MAP2_NORMAL, u_min, u_max,
v_min, v_max, normal_array);
glEnable(GL_MAP2_NORMAL);
Alternatively, have OpenGL compute the normals:
glMap2f(GL_MAP2_VERTEX_3, u_min, u_max,
v_min, v_max, point_array);
glEnable(GL_MAP2_VERTEX_3);
glEnable(GL_AUTO_NORMAL);
TW already enables GL_AUTO_NORMAL, so don't worry about normals
unless you're doing something interesting.
Note that GL_AUTO_NORMAL computes the normal vectors as u x v,
where u is the outer
dimension of our nested arrays of control
points, and v is the inner
dimension.
See Normals.py
for an example that demonstrates this.
The main message of Normals.py, though, is that getting cullface
and normal generation and front/back colors all to play well together
is difficult. If possible, stick to surfaces where you don't have to
worry about the back
side. (If you think about the GLUT
objects, such as spheres and cubes, you never see the back of any
face).
Let's play with
FlagPole.py
Let's look at
CokeBottle.py
Written by Scott D. Anderson
scott.anderson@acm.org

This work is licensed under a Creative Commons
License.