PDA

View Full Version : Help needed on NURB



petric
09-23-2000, 12:24 PM
Hallo,

after nearly one week frustating experiments I ask this community:

I want to display NURB surfaces, read from RenderMan Interface files, with the
OpenGL glNurbSurface call.

I got all data (s&t knots, s&t orders and all control points from the RenderMan files. But I have servere problems displaying surfaces with order > 2.


I have ordered allready the "Curves and Surfaces for Computer-Aided
Geometric Design" by Gerald Farin to get more knowledge in this
area, but it will take about two weeks until it will arrive.

Hopefully somebody can help me at the moment and can explain me my
mistakes:


Here is the RIB file (which was created by Rhino3D) of a simple
sphere with radius 1:


##RenderMan RIB-Structure 1.0
version 3.03

Format 768 384 1
Projection "perspective" "fov" [ 90.0 ]
Identity
Translate 0 0 5
FrameBegin 0
Display "pic1.tif" "file" "rgba"
WorldBegin
Color 1 0 0
NuPatch
9 3
[ 0 0 0 0.25 0.25 0.5 0.5 0.75 0.75 1 1 1 ]
0 1
5 3
[ 0 0 0 0.5 0.5 1 1 1 ]
0 1
"Pw" [ 0 0 1 1 0 0 0.707107 0.707107 0 0 1 1 0 0 0.707107
0.707107 0 0 1 1 0 0 0.707107 0.707107 0 0 1 1 0 0 0.707107
0.707107 0 0 1 1 0.707107 0 0.707107 0.707107 0.5 -0.5
0.5 0.5 1.96262e-016 -0.707107 0.707107 0.707107 -0.5
-0.5 0.5 0.5 -0.707107 -1.17757e-016 0.707107 0.707107
-0.5 0.5 0.5 0.5 7.85046e-017 0.707107 0.707107 0.707107
0.5 0.5 0.5 0.5 0.707107 0 0.707107 0.707107 1 0 0 1
0.707107 -0.707107 0 0.707107 2.77556e-016 -1 0 1
-0.707107 -0.707107 0 0.707107 -1 -1.66533e-016 0 1
-0.707107 0.707107 0 0.707107 1.11022e-016 1 0 1
0.707107 0.707107 0 0.707107 1 0 0 1 0.707107 0 -0.707107
0.707107 0.5 -0.5 -0.5 0.5 1.96262e-016 -0.707107
-0.707107 0.707107 -0.5 -0.5 -0.5 0.5 -0.707107
-1.17757e-016 -0.707107 0.707107 -0.5 0.5 -0.5 0.5
7.85046e-017 0.707107 -0.707107 0.707107 0.5 0.5 -0.5
0.5 0.707107 0 -0.707107 0.707107 0 0 -1 1 0 0 -0.707107
0.707107 0 0 -1 1 0 0 -0.707107 0.707107 0 0 -1 1 0 0
-0.707107 0.707107 0 0 -1 1 0 0 -0.707107 0.707107 0 0 -1 1 ]
WorldEnd
FrameEnd


--------------------------------------------------------------------------

And this is the way in C how I tryed to display the surface:


int nu = 9;
int uorder = 3;
float uknot[] = {0, 0, 0, 0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 1, 1, 1};
int nuknot = nu+uorder;

int nv = 5;
int vorder = 3;
float vknot[] = {0, 0, 0, 0.5, 0.5, 1, 1, 1};
int nvknot = nv+vorder;

float ctl[9][5][4] = {{{ 0, 0, 1, 1}, { 0, 0, 0.707107, 0.707107},
...
}}};
GLUnurbsObj *pNurb;


pNurb = gluNewNurbsRenderer();
gluBeginSurface(pNurb);

gluNurbsSurface(
pNurb,
nuknot, uknot, nvknot, vknot,
nv*4, // u_stride
size, // v_stride
&ctl[0][0][0],
uorder, vorder,
GL_MAP2_VERTEX_4);

gluEndSurface(pNurb);

----------------------------------------------------------------------

If there are important parts of the program missing, do not hesitate to
ask for them. (I wanted to keep this posting as short as possible:-)

Many thanks in advance,

Greetings Felix