Results 1 to 4 of 4

Thread: How to draw a hemisphere?

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    1

    How to draw a hemisphere?

    Hi there, I'm fairly new to OpenGL and was wondering how I can make a function that takes in 2 arguments to draw a hemisphere. I was going to use glClipPlane with gluSphere but I have certain requirements for this problem:

    I'm required to use GN_LINE_LOOP to draw the hemisphere in wire frame, compute a surface normal for each vertex and call glNormal3f() before each glVertex3f() call in order to assign a correct surface normal to each vertex, and change to using GL POLYGON,GL QUADS, or GL QUAD STRIP, thus producing a solid-shaded hemisphere. I'm allowed to use GL TRIANGLES
    or GL TRIANGLE STRIP at the pole, or I can just co-locate two vertices in a quad representation.

    Thanks in advance!

  2. #2
    Senior Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    356

    Re: How to draw a hemisphere?

    Hi, I'm not going to solve your problem, your professor wouldn't approve. :P
    But let's try to think a little bit about it.
    Using the gluSphere is an horrible solution, it's slow, you don't have any control on witch technique is used. In real world you need to have full control of what you are sending to the GPU.

    Now thinks a little bit about your assignment. The normal of a sphere (or a semi-sphere) are pretty easy, they came from the center, so the normal will be
    normal = (currentPoint - center)/module(currentPoint-center)
    To find the current point is also pretty easy: a sphere (in the origin) is x^2+y^2 = r^2
    so if you switch to polar coordinates
    x = r sin (theta) cos (phi)
    y = r cos (theta) sin (phi)
    z = r cos (theta)
    if you make a double for loop on theta and phi you can easily find the point coordinate on the sphere.
    Now you only have to iterate in the correct way to send the triangles.
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Oct 2009
    Posts
    592

    Re: How to draw a hemisphere?

    The most easy way is to model your hemisphere in a modeling program (blender). Then export it into a file and import it into a program. Maybe you can preprocess it with a stripper too.

  4. #4
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789

    Re: How to draw a hemisphere?

    There are plenty of algorithms for drawing full spheres online and you should be able to adapt one of those to a hemisphere easily enough. A hint: what's the normal for each vertex in a sphere of radius 1? (You should be able to look this up too.)

Similar Threads

  1. To draw hemisphere (half sphere)
    By Numan.pk in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-25-2013, 06:21 AM
  2. How to draw a Umbrella, Bell or Hemisphere?
    By Ricardo Sanchez in forum OpenGL: General
    Replies: 3
    Last Post: 10-14-2009, 02:23 AM
  3. draw hemisphere using glusphere
    By edwong in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-06-2003, 07:22 PM
  4. How do I draw a wire frame Hemisphere?
    By songeb in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 06-03-2002, 01:22 AM
  5. How can I draw a hemisphere and a half-cylinder?
    By Kyung-ho Ahn in forum OpenGL: User Software
    Replies: 0
    Last Post: 06-29-2000, 09:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean