Hi all,
I’m trying to write a program that models an outdoor scene and part of the scene involves an amphitheater that I’ve rendered using NURBS. Now, I’m trying to use texturing and lighting on the object, but am having trouble calculating the normals for the object. There are several parts to the actual theater, so I’ll include just one of the sets of control points here. I’m using a 4th order NURB to get this done.
My question is, how do I calculate the Normals? Is it just like calculating normals for Linear objects? Any help you can give is appreciated:
float restnear[4][4][3] = { 8.0, -10.0, 0.0,
8.0, -5.0, 0.0,
8.0, 5.0, -4.0,
8.0, 10.0, -6.0,
6.0, -10.0, 0.0,
6.0, -5.0, 0.0,
6.0, 5.0, -4.0,
6.0, 10.0, -6.0,
2.0, -10.0, 0.0,
2.0, -5.0, 0.0,
2.0, 5.0, -4.0,
2.0, 10.0, -6.0,
0.0, -10.0, 0.0,
0.0, -5.0, 0.0,
0.0, 5.0, -4.0,
0.0, 10.0, -6.0 };float restnearnorm[4][4][3] = { 0.0, 0.0, -1.0,
0.0, 0.0, -1.0,
0.0, -1.0, -1.0,
0.0, -1.0, -1.0,
0.0, 0.0, -1.0,
0.0, 0.0, -1.0,
0.0, -1.0, -1.0,
0.0, -1.0, -1.0,
0.0, 0.0, -1.0,
0.0, 0.0, -1.0,
0.0, -1.0, -1.0,
0.0, -1.0, -1.0,
0.0, 0.0, -1.0,
0.0, 0.0, -1.0,
0.0, -1.0, -1.0,
0.0, -1.0, -1.0 };gluNurbsSurface(theNurb,
8, knots, 8, knots,
4 * 3, 3, &restnear[0][0][0],
4, 4, GL_MAP2_NORMAL);
gluNurbsSurface(theNurb,
8, knots, 8, knots,
4 * 3, 3, &restnear[0][0][0],
4, 4, GL_MAP2_VERTEX_3);
gluNurbsSurface(theNurb,
8, knots, 8, knots,
4 * 3, 3, &restnear[0][0][0],
4, 4, GL_MAP2_TEXTURE_COORD_2);gluEndSurface(theNurb);