My task is to build a b-spline surface and cut a hole in it in the form of a pentagon.
To do this, I use the gluBeginTrim() and gluEndTrim() code block. However, my approach does not work, the hole is not cut, but the surface is cut. I have already tried to select the coordinates for the vertices of the pentagon - nothing works.
Maybe my approach is not correct at all? Tell me
GLfloat ctrlpoints[4][4][3] = {
{{-1.5, -1.5, 4.0}, {-0.5, -1.5, 2.0}, {0.5, -1.5, -1.0}, {1.5, -1.5, 2.0}},
{{-1.5, -0.5, 1.0}, {-0.5, -0.5, 3.0}, {0.5, -0.5, 0.0}, {1.5, -0.5, -1.0}},
{{-1.5, 0.5, 4.0}, {-0.5, 0.5, 0.0}, {0.5, 0.5, 3.0}, {1.5, 0.5, 4.0}},
{{-1.5, 1.5, -2.0}, {-0.5, 1.5, -2.0}, {0.5, 1.5, 0.0}, {1.5, 1.5, -1.0}}
};
GLfloat knots[8] = { 0, 0, 0, 0, 1, 1, 1, 1 };
GLfloat pentagonPoints[5][3] = {
{-0.5, 1.5, -0.5},
{0.0, 1.5, -1.0},
{0.5, 1.5, -0.5},
{0.5, 1.5, 0.5},
{-0.5, 1.5, -0.5}
};
void displayBSpline()
{
int i, j;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0.0, 0.0, 1.0);
glPushMatrix();
glRotatef(t, 1.0, 1.0, 1.0);
GLUnurbsObj* nurbsObject = gluNewNurbsRenderer();
gluNurbsProperty(nurbsObject, GLU_SAMPLING_TOLERANCE, 25.0);
gluNurbsProperty(nurbsObject, GLU_DISPLAY_MODE, GLU_OUTLINE_POLYGON);
gluNurbsProperty(nurbsObject, GLU_AUTO_LOAD_MATRIX, GL_TRUE);
gluBeginSurface(nurbsObject);
gluNurbsSurface(nurbsObject, 8, knots, 8, knots, 4 * 3, 3, &ctrlpoints[0][0][0], 4, 4, GL_MAP2_VERTEX_3);
gluBeginTrim(nurbsObject);
gluPwlCurve(nurbsObject, 5, pentagonPoints[0], 3, GLU_MAP1_TRIM_2);
gluEndTrim(nurbsObject);
gluEndSurface(nurbsObject);
glPopMatrix();
glFlush();
}