Question

I am using OpenGL to create a nurbs surface (gluNurbSurface(...)) and I would like to know how reach the normal value to the control points(black dot) to the surface market as a red dot. With this information I will be able to calculate the distance between them.

Nurbs

Added In order to get another answers or improve the subjected I would like to write part of the code, I hope can get more help:

In this part you can observe how I initialize the nurbs.

init_surface();

   theNurb = gluNewNurbsRenderer();
   gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 50.0);
   gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL);
   gluNurbsCallback(theNurb, GLU_ERROR, 
                    (GLvoid (*)()) nurbsError);

Next the surface is created with their parameters.

gluBeginSurface(theNurb);
    gluNurbsSurface(theNurb,
            U+ordenU, knotsU,
            V+ordenV, knotsV,
            V * 3,
            3,
            &ctlpoints[0][0][0],
            ordenU, ordenV,
            GL_MAP2_VERTEX_3);

   gluEndSurface(theNurb);

Remember I am using C. And in this moment I am trying to introduce the values of the nurbs into a vector with the function proposed by genpfault in the first answer but I do not know in which part I have to add them.

Était-ce utile?

La solution

Set a GLU_NURBS_NORMAL_DATA callback via gluNurbsCallback(). A GLU_NURBS_VERTEX_DATA callback would also be useful.

Point *userData (via gluNurbsCallbackData()) at some sort of dynamic array data-structure to hold the points/normals. If you were using C++ I'd recommend a std::vector of Eigen::Vector3fs.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top