Creating a 3D Sphere using Android GL

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

Creating a 3D Sphere using Android GL

Postby whreckz » Wed May 14, 2008 2:04 am

Hi Guys,
I've trying this for a few days... can somebody help on how to create a 3d sphere in androidGL. most of the samples here are cubes, squares and triangles...
I've seen some examples in the web... regarding 3D Sphere but i can't find the API's that I need to use in android...
Please give me some light. :D

regards,

Rex
whreckz
Freshman
Freshman
 
Posts: 9
Joined: Wed May 07, 2008 3:59 am
Location: Manila, Philippines

Top

Postby shredder » Wed May 14, 2008 10:57 am

Android GLUT does not have many functionalities, and sphere generation is the lacking one. I believe you'll have to generate the vertices and indices buffer manually.

What I have done with sky dome ( half a sphere ) is something like this. Unfortunately, my coworker did the maths, so I can only give you the idea:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. vertices = new float[NUM_VERTICES];
  2.  
  3. voffset = 0;
  4.  
  5. y = 0;
  6.  
  7. radius = 100.0f;
  8.  
  9. while( y < HEIGHT )
  10.  
  11. {
  12.  
  13.   voffset += generateCircleVertices( vertices, voffset, y, radius );
  14.  
  15.   radius -= 1.0f;
  16.  
  17.   y += 1.0f;
  18.  
  19. }
  20.  
  21. indices = generateSkyDomeIndices();
  22.  
  23.  
  24.  
  25.  
  26.  
  27. int generateCircleVertices( float[] arr, int offset, float y, float r )
  28.  
  29. {
  30.  
  31.    < use your maths to generate a number of vertices of a circle >
  32.  
  33.    < the more vertices, the nicer the dome will look >
  34.  
  35. }
  36.  
  37.  
  38.  
  39. short[] generateSkyDomeIndices()
  40.  
  41. {
  42.  
  43.    < lots of brain work here >
  44.  
  45. }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
shredder
Junior Developer
Junior Developer
 
Posts: 12
Joined: Mon Mar 03, 2008 2:34 pm

Postby whreckz » Wed May 14, 2008 11:04 am

hi,
Thanks for your quick reply. Not much of a help but it gave me a lot of ideas. Again, thanks
whreckz
Freshman
Freshman
 
Posts: 9
Joined: Wed May 07, 2008 3:59 am
Location: Manila, Philippines

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests