-1

I am using OpenTK (a c# wrapper of OpenGL) to draw a NURBS surface calculated with Cox-deBoor algorithm. The algorithm gives individual points on the surface. How can I render the whole surface from these points? In addition, how can I draw a wireframe of these points?

Thanks!

Berlyne
  • 1
  • 2

1 Answers1

0

First you need to generate a grid of individual points on the surface. If your surface parameters go between 0 and 1, let's say that you generate points every 0.05. In that way you will have a grid of 200x200 = 40000 points. (from your post I get that you have already done this)

Then you can draw your surface using GL_QUADS, for every group of 4 points in your grid. For example your first QUAD will be:

  • Surface.Evaluate_UV(0, 0)
  • Surface.Evaluate_UV(0.05, 0)
  • Surface.Evaluate_UV(0.05, 0.05)
  • Surface.Evaluate_UV(0, 0.05)

You will have to do the same for every "cell" in the grid.

Finally, if you want to see the surface as wireframe, you have 2 options: 1st option. Use the code:

// This option renders the surface in wireframe mode GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); // This option renders the surface in shaded mode GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);

2nd option. Use GL_LINES instead of GL_QUADS to draw the lines that will form the wireframe model.

leandro
  • 167
  • 8