Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  World with lat n long circles  (Read 491 times)
0 Members and 1 Guest are viewing this topic.
Offline digitalcool

JGO n00b
*

Posts: 1



« on: 2005-08-07 14:51:58 »

Hi guys, neebie here newly working in the world of 3d graphics.  I'm looking to make the first step in creating a globe. I am looking to first off create a wire frame of the globe With the only lines representing sections of lat and longs...essentially just layered circles, no triangles.  I'll be using this model in a mapped coordinate system later, and wanna be sure I get off on the right track.  Any help, comments, or suggestions would be appreciated.  Thanks for you help.

-me
Offline turquoise3232

Sr. Member
**

Posts: 332


Java (games) rock!


« Reply #1 on: 2005-08-07 16:19:28 »

Using the following code and setting polygon mode to wire should do what you want...

            private void drawMapedSphere ( GL gl )
            {
                int n =64;
               
                double x = 0;
                double y = 0;
                double z = 0;
               
                double phi1, phi2, theta;
               
                for( int i = 0; i < n; i++ )
                {
                    phi1 = i * PI / n;
                    phi2 = (i + 1) * PI / n;
                   
                    gl.glBegin ( GL_QUAD_STRIP );
                    for( int j = 0; j <= n; j++ )
                    {
                        theta = j * 2 * PI / n;
                       
                        x = sin ( theta ) * sin ( phi1 );
                        y = cos ( phi1 );
                        z = cos ( theta ) * sin ( phi1 );
                       
                        gl.glNormal3d ( x,y,z );
                        gl.glTexCoord2d ( 0.5 + (double)j / n, (double)i / n );
                        gl.glVertex3d ( x,y,z );
                       
                        x = sin ( theta ) * sin ( phi2 );
                        y = cos ( phi2 );
                        z = cos ( theta ) * sin ( phi2 );
                       
                        gl.glNormal3d ( x,y,z );
                        gl.glTexCoord2d ( 0.5 + (double)j / n, (i+1.0) / n );
                        gl.glVertex3d ( x,y,z );
                    }
                    gl.glEnd ();
                }
            }
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.149 seconds with 21 queries.