View Full Version : creating nurbs
Memoid
10222008, 11:01 AM
Hi All, i'm trying to create a nurbs surface out of a grid of data but am having problems.
I've read http://glprogramming.com/red/chapter12.html and http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/glu/nurbssurface.html and understand most of the process, except what to pass the function.
I call gluNewNurbsRenderer(); to create the surface
gluNurbsProperty() to set a bunch or properties
and to draw
gluBeginSurface(nurb);
gluNurbsSurface(nurb, ..., GL_MAP2_VERTEX_3);
gluEndSurface(nurb);
but what I'm confused about, is what to pass gluNurbsSurface. I have a 2 dimensional array of vec3s, which are the 3D coordinates of my points. It is an evenly spaced grid, deformed in space. And I would like to draw a smooth surface going through these points. What would be my knots vector in this case? or my control points?
trinitrotoluene
10222008, 11:54 AM
Finding the parameters (control points,minimum order,knot vectors) of a NURBS surface that will pass exactly or near each of your vertex in your vec3 array is very difficult.Maybe you can use your array of vec3 as control points but the surface will not pass through the vertices of your array. Your problem is more a interpolation one. Kriging (http://en.wikipedia.org/wiki/Kriging) is an interpolation technique that may suit your need but require some (a lot) mathematical knowledge. Maybe some simpler piecewise interpolation (http://en.wikipedia.org/wiki/Interpolation) technique can be used. Maybe you can use a third party software (Octave/Matlab) to calculate intermediate vertices of your surface for you.
Memoid
10222008, 04:51 PM
Hi, thanks for the response. Unfortunately a 3rd party software is out of the question as I was hoping for a realtime solution.
I'm running a kind of paper/cloth simulation using a bunch of particles laid out in a grid, with springs connecting all of the neighboring particles (a bit like this http://vimeo.com/1840876 but organized in a grid). The simulation is dynamic and interactive, and I would like to render the resulting surface at higher resolution than the physical resolution. I know I can do it using catmullrom first in one direction, and then in another... but its a lot of code to write and I'd never used openGL surfaces before and thought I'd give it a shot. So I guess its not very usable for my situation?
*EDIT*
this isn't meant to be a realistic simulation, so I dont need the surface to go exactly through all of the points just as long as one gets an idea of the interaction... dunno if that makes it easier...
trinitrotoluene
10222008, 05:18 PM
Knowing that a Bézier surface pass through is control points at it's border, one solution is to add vertices in somewhere in the middle of the convex hull of each 4 points. Then use a knots vector so that keep the order of Bézier low (3 or 4) for numerical precision. As an example knots vectors are:
[0 0 .33 .33 .66 .66 1 1] for u
[0 0 0 1 1 1] for v
So I think with these knots vectors the surface will pass trough the + vertices and * at the boundary of the patch.
+*+  *  +
  
* * * * *
  
+*+ * *
v


> u
+ = original vertices in the mesh
* = added vertices
 and  are patch boundary
But the problem is that control points between adjacent patches
have to be collinear to not introduce discontinuities in the whole surface.
Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.