How to draw a trimmed sphere in OpenGL?

Hi all,

I want to draw a sphere with radius of 100.0 and center located at (0,0,0) and cut by a plane x=50. That means the sphere is trimmed by circle liying in plane x=50 having radius of 86.6025 located at (50,0,0).

I use gluNurbSurface function to draw the untrimmed sphere and trim it with gluNurbCurve within gluBeginTrim/gluEndTrim pair. Parameters are showed below.

But nothing is display.

What’s wrong with the model.

Thanks.

Dan.

NURBS surface (sphere) parameters

u knots: 8

-1.570796,-1.570796,-1.570796,0.000000,0.000000,1.570796,1.570796,1.570796

v knots: 12

0.000000,0.000000,0.000000,1.570796,1.570796,3.141593,3.141593,4.712389,4.712389,6.283185,6.283185,6.283185

#control points: 5x9
0.000000,0.000000,-100.000000,1.000000
0.000000,-0.000000,-70.710678,0.707107
0.000000,-0.000000,-100.000000,1.000000
-0.000000,-0.000000,-70.710678,0.707107
-0.000000,-0.000000,-100.000000,1.000000
-0.000000,0.000000,-70.710678,0.707107
-0.000000,0.000000,-100.000000,1.000000
0.000000,0.000000,-70.710678,0.707107
0.000000,0.000000,-100.000000,1.000000
-70.710678,-0.000000,-70.710678,0.707107
-50.000000,50.000000,-50.000000,0.500000
-0.000000,70.710678,-70.710678,0.707107
50.000000,50.000000,-50.000000,0.500000
70.710678,0.000000,-70.710678,0.707107
50.000000,-50.000000,-50.000000,0.500000
0.000000,-70.710678,-70.710678,0.707107
-50.000000,-50.000000,-50.000000,0.500000
-70.710678,-0.000000,-70.710678,0.707107
-100.000000,-0.000000,0.000000,1.000000
-70.710678,70.710678,0.000000,0.707107
-0.000000,100.000000,0.000000,1.000000
70.710678,70.710678,0.000000,0.707107
100.000000,0.000000,0.000000,1.000000
70.710678,-70.710678,0.000000,0.707107
0.000000,-100.000000,0.000000,1.000000
-70.710678,-70.710678,0.000000,0.707107
-100.000000,-0.000000,0.000000,1.000000
-70.710678,-0.000000,70.710678,0.707107
-50.000000,50.000000,50.000000,0.500000
-0.000000,70.710678,70.710678,0.707107
50.000000,50.000000,50.000000,0.500000
70.710678,0.000000,70.710678,0.707107
50.000000,-50.000000,50.000000,0.500000
0.000000,-70.710678,70.710678,0.707107
-50.000000,-50.000000,50.000000,0.500000
-70.710678,-0.000000,70.710678,0.707107
0.000000,0.000000,100.000000,1.000000
0.000000,-0.000000,70.710678,0.707107
0.000000,-0.000000,100.000000,1.000000
-0.000000,-0.000000,70.710678,0.707107
-0.000000,-0.000000,100.000000,1.000000
-0.000000,0.000000,70.710678,0.707107
-0.000000,0.000000,100.000000,1.000000
0.000000,0.000000,70.710678,0.707107
0.000000,0.000000,100.000000,1.000000

Trimming NURBS curve parameters

knots: 12

-3.141593,-3.141593,-3.141593,-1.570796,-1.570796,-0.000000,-0.000000,1.570796,1.570796,3.141593,3.141593,3.141593

control points: 9

50.000000,-0.000000,86.602540
50.000000,86.602540,86.602540
50.000000,86.602540,0.000000
50.000000,86.602540,-86.602540
50.000000,0.000000,-86.602540
50.000000,-86.602540,-86.602540
50.000000,-86.602540,-0.000000
50.000000,-86.602540,86.602540
50.000000,-0.000000,86.602540

weghts:
1.000000,0.707107,1.000000,0.707107,1.000000,0.707107,1.000000,0.707107,1.000000

In fact, the data come from AutoDesk’s AutoCAD drawing.

Hi !

Wouldn’t it be much easier to just enable a clipping plane and use that to do the clipping ? unless you need some other fancy stuff…

Mikael

It’s only a sample. In fact i have a lot of faces trimmed by complex curves.

Thanks for response.

Originally posted by mikael_aronsson:
[b]Hi !

Wouldn’t it be much easier to just enable a clipping plane and use that to do the clipping ? unless you need some other fancy stuff…

Mikael[/b]