0
GLUnurbsObj *theNurb;

theNurb = gluNewNurbsRenderer();
gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 5.0);
gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL);

//ctrPoint[] is an array containing the coordinate x,y,z of a grid size of 15*15. 
// therefore, the # of control points is 15*15=225. The degree is 3 and
// the order is 4.The size of knot vector is 4+225 = 229.   

void drawNurbs(){
    float knots[229];
    for (int i=0;i<114;i++)
    {
        knots[i] = 0;
    }
    for (int i=114;i<229;i++)
    {
        knots[i] = 1;
    }

    gluBeginSurface(theNurb);
    gluNurbsSurface(theNurb, 229, knots, 229, knots, 15*3 , 3, &ctrPoint[0], 
        4, 4, GL_MAP2_VERTEX_3);
    gluEndSurface(theNurb);

}

void display(){
    drawNurbs();
}

上面的代码不起作用。drawNurbs() 函数有问题。但我不知道我错在哪里。尺寸ctrPoint[]为 225*3。

4

1 回答 1

0

我发现了问题。

(1) 第一个4结元素为 0 !

(2)节数应该是15+4=19而不是229!!

GLfloat ctrlpoints[s_count][t_count][type]; //ctrlPoints[15][15][3]
GLfloat sknot[sknot_count];                 
GLfloat tknot[tknot_count];

然后

sknot_count = s_count + sorder; // 19 = 15+4
tknot_count = t_count + torder; // 19=15+4
于 2011-11-11T02:12:02.817 回答