// --- Basecode Methods --- #region Initialize() /// <summary> /// Overrides OpenGL's initialization. /// </summary> public override void Initialize() { // Initialize material property and depth buffer float[] mat_diffuse = { 0.7f, 0.7f, 0.7f, 1.0f }; float[] mat_specular = { 1.0f, 1.0f, 1.0f, 1.0f }; float[] mat_shininess = { 100.0f }; glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); glEnable(GL_AUTO_NORMAL); glEnable(GL_NORMALIZE); InitSurface(); theNurb = gluNewNurbsRenderer(); gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0f); gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); }
// --- Basecode Methods --- #region Initialize() /// <summary> /// Overrides OpenGL's initialization. /// </summary> public override void Initialize() { // Initialize material property, light source, lighting model, and depth buffer float[] mat_ambient = { 1.0f, 1.0f, 1.0f, 1.0f }; float[] mat_diffuse = { 1.0f, 0.2f, 1.0f, 1.0f }; float[] mat_specular = { 1.0f, 1.0f, 1.0f, 1.0f }; float[] mat_shininess = { 50.0f }; float[] light0_position = { 1.0f, 0.1f, 1.0f, 0.0f }; float[] light1_position = { -1.0f, 0.1f, 1.0f, 0.0f }; float[] lmodel_ambient = { 0.3f, 0.3f, 0.3f, 1.0f }; glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT1, GL_POSITION, light1_position); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); glEnable(GL_AUTO_NORMAL); theNurb = gluNewNurbsRenderer(); gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0f); gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); float[/*S_NUMPOINTS*/, /*T_NUMPOINTS*/, /*4*/] ctlpoints = { { { 4.0f, 2.0f, 2.0f, 1.0f }, { 4.0f, 1.6f, 2.5f, 1.0f }, { 4.0f, 2.0f, 3.0f, 1.0f } }, { { 5.0f, 4.0f, 2.0f, 1.0f }, { 5.0f, 4.0f, 2.5f, 1.0f }, { 5.0f, 4.0f, 3.0f, 1.0f } }, { { 6.0f, 5.0f, 2.0f, 1.0f }, { 6.0f, 5.0f, 2.5f, 1.0f }, { 6.0f, 5.0f, 3.0f, 1.0f } }, { { SQRT2 * 6.0f, SQRT2 * 6.0f, SQRT2 * 2.0f, SQRT2 }, { SQRT2 * 6.0f, SQRT2 * 6.0f, SQRT2 * 2.5f, SQRT2 }, { SQRT2 * 6.0f, SQRT2 * 6.0f, SQRT2 * 3.0f, SQRT2 } }, { { 5.2f, 6.7f, 2.0f, 1.0f }, { 5.2f, 6.7f, 2.5f, 1.0f }, { 5.2f, 6.7f, 3.0f, 1.0f } }, { { SQRT2 * 4.0f, SQRT2 * 6.0f, SQRT2 * 2.0f, SQRT2 }, { SQRT2 * 4.0f, SQRT2 * 6.0f, SQRT2 * 2.5f, SQRT2 }, { SQRT2 * 4.0f, SQRT2 * 6.0f, SQRT2 * 3.0f, SQRT2 } }, { { 4.0f, 5.2f, 2.0f, 1.0f }, { 4.0f, 4.6f, 2.5f, 1.0f }, { 4.0f, 5.2f, 3.0f, 1.0f } }, { { SQRT2 * 4.0f, SQRT2 * 6.0f, SQRT2 * 2.0f, SQRT2 }, { SQRT2 * 4.0f, SQRT2 * 6.0f, SQRT2 * 2.5f, SQRT2 }, { SQRT2 * 4.0f, SQRT2 * 6.0f, SQRT2 * 3.0f, SQRT2 } }, { { 2.8f, 6.7f, 2.0f, 1.0f }, { 2.8f, 6.7f, 2.5f, 1.0f }, { 2.8f, 6.7f, 3.0f, 1.0f } }, { { SQRT2 * 2.0f, SQRT2 * 6.0f, SQRT2 * 2.0f, SQRT2 }, { SQRT2 * 2.0f, SQRT2 * 6.0f, SQRT2 * 2.5f, SQRT2 }, { SQRT2 * 2.0f, SQRT2 * 6.0f, SQRT2 * 3.0f, SQRT2 } }, { { 2.0f, 5.0f, 2.0f, 1.0f }, { 2.0f, 5.0f, 2.5f, 1.0f }, { 2.0f, 5.0f, 3.0f, 1.0f } }, { { 3.0f, 4.0f, 2.0f, 1.0f }, { 3.0f, 4.0f, 2.5f, 1.0f }, { 3.0f, 4.0f, 3.0f, 1.0f } }, { { 4.0f, 2.0f, 2.0f, 1.0f }, { 4.0f, 1.6f, 2.5f, 1.0f }, { 4.0f, 2.0f, 3.0f, 1.0f } } }; int cnt = 0; for (int i = 0; i < S_NUMPOINTS; i++) { for (int j = 0; j < T_NUMPOINTS; j++) { for (int k = 0; k < 4; k++) { pointdata[cnt] = ctlpoints[i, j, k]; cnt++; } } } }