src/objects3D/TexSphere.java
public void DrawTexSphere(float radius,float nSlices,float nSegments,Texture myTexture) {
		float x,y,z;
		float s,t; // texture coordinates
		
		   float inctheta = (float) ((2.0f*Math.PI )/ nSlices );
		    float incphi   = (float) (Math.PI/ nSegments );
		    
		   
		    
		    GL11.glBegin(GL11.GL_QUADS);
		    for(float theta=(float) -Math.PI; theta<Math.PI; theta+=inctheta)
		    {
		        for(float phi=(float) -(Math.PI/2.0f); phi<(Math.PI/2.0f); phi+=incphi)
		        {
		            x = (float) (Math.cos(phi)* Math.cos(theta)*radius);
		            y =  (float) (Math.cos(phi)* Math.sin(theta)*radius);
		            z =  (float) (Math.sin(phi)*radius);
		            
		            t =   (float) (phi/(float)Math.PI) +0.5f; 
		            s =    (float) (theta/Math.PI*2.0f) +0.5f ; 
		            
		            //GL11.glTexCoord2f(s,t);  // should be here but seems to be a bug in LWJGL 
		            GL11.glNormal3f(x,y,z); 
		            GL11.glVertex3f(x,y,z);  
			           
		            x = (float) (Math.cos(phi)*Math.cos(theta+inctheta)*radius);
		            y = (float) (Math.cos(phi)*Math.sin(theta+inctheta)*radius);
		            z = (float) (Math.sin(phi)*radius);
		            t = (float) (((float)phi/(float)Math.PI)+0.5f); 
		            s = (float) ((((float)theta+inctheta)/((float)Math.PI*2.0f)))+0.5f; 
		           
		            GL11.glTexCoord2f(s,t);
		            
		         
		            GL11.glVertex3f(x,y,z);  // Top Right corner

		            x = (float) (Math.cos(phi+incphi)*Math.cos(theta+inctheta)*radius);
		            y = (float) (Math.cos(phi+incphi)*Math.sin(theta+inctheta)*radius);
		            z = (float) (Math.sin(phi+incphi)*radius);
		            t = (float) ((((float)phi+incphi)/(float)Math.PI)+0.5f);
		            s = (float) ((((float)theta+inctheta)/((float)Math.PI*2.0f))+0.5f);
		         
		            GL11.glTexCoord2f(s,t);
		            GL11.glNormal3f(x,y,z);
		            GL11.glVertex3f(x,y,z); 

		            x = (float) (Math.cos(phi+incphi)*Math.cos(theta)*radius);
		            y = (float) (Math.cos(phi+incphi)*Math.sin(theta)*radius);
		            z = (float) (Math.sin(phi+incphi)*radius);
		            t = (float) ((((float)phi+incphi)/(float)Math.PI)+0.5f);
		            s = (float) (((float)theta/((float)Math.PI*2.0f))+0.5f);
		            
		            GL11.glTexCoord2f(s,t);
		            GL11.glNormal3f(x,y,z);
		            GL11.glVertex3f(x,y,z);  
		        }
		    }
		    GL11.glEnd();
	}
// 7b should be your primary source, we will cover more about circles in later lectures to understand why the code works 
7b should be your primary source, we will cover more about circles in later lectures to understand why the code works
7b should be your primary source we will cover more about circles in later lectures to understand why the code works
public void DrawTexSphere(float radius,float nSlices,float nSegments,Texture myTexture) {
		float x,y,z;
		float s,t; 
		   float inctheta = (float) ((2.0f*Math.PI )/ nSlices );
		    float incphi   = (float) (Math.PI/ nSegments );
		    GL11.glBegin(GL11.GL_QUADS);
		    for(float theta=(float) -Math.PI; theta<Math.PI; theta+=inctheta)
		    {
		        for(float phi=(float) -(Math.PI/2.0f); phi<(Math.PI/2.0f); phi+=incphi)
		        {
		            x = (float) (Math.cos(phi)* Math.cos(theta)*radius);
		            y =  (float) (Math.cos(phi)* Math.sin(theta)*radius);
		            z =  (float) (Math.sin(phi)*radius);
		            t =   (float) (phi/(float)Math.PI) +0.5f; 
		            s =    (float) (theta/Math.PI*2.0f) +0.5f ; 
		            GL11.glNormal3f(x,y,z); 
		            GL11.glVertex3f(x,y,z);  
		            x = (float) (Math.cos(phi)*Math.cos(theta+inctheta)*radius);
		            y = (float) (Math.cos(phi)*Math.sin(theta+inctheta)*radius);
		            z = (float) (Math.sin(phi)*radius);
		            t = (float) (((float)phi/(float)Math.PI)+0.5f); 
		            s = (float) ((((float)theta+inctheta)/((float)Math.PI*2.0f)))+0.5f; 
		            GL11.glTexCoord2f(s,t);
		            GL11.glVertex3f(x,y,z);  
		            x = (float) (Math.cos(phi+incphi)*Math.cos(theta+inctheta)*radius);
		            y = (float) (Math.cos(phi+incphi)*Math.sin(theta+inctheta)*radius);
		            z = (float) (Math.sin(phi+incphi)*radius);
		            t = (float) ((((float)phi+incphi)/(float)Math.PI)+0.5f);
		            s = (float) ((((float)theta+inctheta)/((float)Math.PI*2.0f))+0.5f);
		            GL11.glTexCoord2f(s,t);
		            GL11.glNormal3f(x,y,z);
		            GL11.glVertex3f(x,y,z); 
		            x = (float) (Math.cos(phi+incphi)*Math.cos(theta)*radius);
		            y = (float) (Math.cos(phi+incphi)*Math.sin(theta)*radius);
		            z = (float) (Math.sin(phi+incphi)*radius);
		            t = (float) ((((float)phi+incphi)/(float)Math.PI)+0.5f);
		            s = (float) (((float)theta/((float)Math.PI*2.0f))+0.5f);
		            GL11.glTexCoord2f(s,t);
		            GL11.glNormal3f(x,y,z);
		            GL11.glVertex3f(x,y,z);  
		        }
		    }
		    GL11.glEnd();
	}
public void DrawTexSphere ( float radius , float nSlices , float nSegments , Texture myTexture ) { float x , y , z ; float s , t ; float inctheta = ( float ) ( ( 2.0f * Math . PI ) / nSlices ) ; float incphi = ( float ) ( Math . PI / nSegments ) ; GL11 . glBegin ( GL11 . GL_QUADS ) ; for ( float theta = ( float ) - Math . PI ; theta < Math . PI ; theta += inctheta ) { for ( float phi = ( float ) - ( Math . PI / 2.0f ) ; phi < ( Math . PI / 2.0f ) ; phi += incphi ) { x = ( float ) ( Math . cos ( phi ) * Math . cos ( theta ) * radius ) ; y = ( float ) ( Math . cos ( phi ) * Math . sin ( theta ) * radius ) ; z = ( float ) ( Math . sin ( phi ) * radius ) ; t = ( float ) ( phi / ( float ) Math . PI ) + 0.5f ; s = ( float ) ( theta / Math . PI * 2.0f ) + 0.5f ; GL11 . glNormal3f ( x , y , z ) ; GL11 . glVertex3f ( x , y , z ) ; x = ( float ) ( Math . cos ( phi ) * Math . cos ( theta + inctheta ) * radius ) ; y = ( float ) ( Math . cos ( phi ) * Math . sin ( theta + inctheta ) * radius ) ; z = ( float ) ( Math . sin ( phi ) * radius ) ; t = ( float ) ( ( ( float ) phi / ( float ) Math . PI ) + 0.5f ) ; s = ( float ) ( ( ( ( float ) theta + inctheta ) / ( ( float ) Math . PI * 2.0f ) ) ) + 0.5f ; GL11 . glTexCoord2f ( s , t ) ; GL11 . glVertex3f ( x , y , z ) ; x = ( float ) ( Math . cos ( phi + incphi ) * Math . cos ( theta + inctheta ) * radius ) ; y = ( float ) ( Math . cos ( phi + incphi ) * Math . sin ( theta + inctheta ) * radius ) ; z = ( float ) ( Math . sin ( phi + incphi ) * radius ) ; t = ( float ) ( ( ( ( float ) phi + incphi ) / ( float ) Math . PI ) + 0.5f ) ; s = ( float ) ( ( ( ( float ) theta + inctheta ) / ( ( float ) Math . PI * 2.0f ) ) + 0.5f ) ; GL11 . glTexCoord2f ( s , t ) ; GL11 . glNormal3f ( x , y , z ) ; GL11 . glVertex3f ( x , y , z ) ; x = ( float ) ( Math . cos ( phi + incphi ) * Math . cos ( theta ) * radius ) ; y = ( float ) ( Math . cos ( phi + incphi ) * Math . sin ( theta ) * radius ) ; z = ( float ) ( Math . sin ( phi + incphi ) * radius ) ; t = ( float ) ( ( ( ( float ) phi + incphi ) / ( float ) Math . PI ) + 0.5f ) ; s = ( float ) ( ( ( float ) theta / ( ( float ) Math . PI * 2.0f ) ) + 0.5f ) ; GL11 . glTexCoord2f ( s , t ) ; GL11 . glNormal3f ( x , y , z ) ; GL11 . glVertex3f ( x , y , z ) ; } } GL11 . glEnd ( ) ; }
7b should be your primary source, we will cover more about circles in later lectures to understand why the code works
7b should be your primary source we will cover more about circles in later lectures to understand why the code works
// texture coordinates //GL11.glTexCoord2f(s,t);  // should be here but seems to be a bug in LWJGL  // Top Right corner