Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: How to draw a trimmed sphere in OpenGL?

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2003
    Posts
    2

    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.570 796

    # v knots: 12
    0.000000,0.000000,0.000000,1.570796,1.570796,3.141 593,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.141 593

    # 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.707 107,1.000000,0.707107,1.000000

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

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,651

    Re: How to draw a trimmed sphere in OpenGL?

    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

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2003
    Posts
    2

    Re: How to draw a trimmed sphere in OpenGL?

    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:
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •