[*Solved*] gluSphere is ruining my space battle game :(

Recommended Posts

Share on other sites
Hmm... Could it be that the last normal value produced for the sphere is being carried over to the rest of your drawing code?

I take it from your use of light 3 that lighting is on and that you're using at least the first two OpenGL lights in your standard drawing somewhere; in that case it might be that the final normal being generated in the call to gluSphere() is being used for your subsequent geometries, and thus producing lighting that differs from your intent.

Perhaps try specifying a normal appropriate to your setup after you've called your sphere.

Share on other sites
Yes, i have 3 different lights, the idea is that they are activated and deactivated as needed by different draw functions.

Normals are something i was hoping to ignore, i dont know much about using them to be honest :( I dont think there would be any manually specificed normals in the code anywhere.

So maybe it's taking the normal of the last face of the sphere, which would be at some odd angle, and applying that to all my flat-on square objects. In which case, specifying a normal straight into the screen after calling gluSphere could fix things?

thanks a lot, i will have a fiddle with this :D

Share on other sites
Thaumaturge, you were absolutely right, thanks so much!

The simple addition of "glNormal3f(0,0,1);" removes all problems. Now here is a 3D planet, with a second blended 3D sphere for the planet atmosphere, and all particles and projectiles looking fine.

I’d never have thought of normals. I could have been fiddling with this for a week, and still have gotten nowhere.

May heaven shower you with eternal blessings :)

Share on other sites
*smiles and bows slightly* It's my pleasure to have helped.

Thank you for your expression of thanks - I appreciate it. ^_^

P.S. Your game is looking good thus far, by the way!

Share on other sites
haha that was such a good reward

Share on other sites
heres an alternative to gluSphere ( does the same thing though )
note - its not optimized, ideally youll stick the whole thing into a single list of tris or quads
void SPHERE::render_sphere_DEBUG( void  ){	float off_H = ( M_PI ) / float(stacks);	float off_R = ( M_PI * 2.0 ) / float(slices);	VEC3 v;	float a,b;	int st,sl;	// draw the tips as tri_fans	glBegin( GL_TRIANGLE_FAN );		v.x = sin( 0.0 ) * sin( 0.0 );		v.z = cos( 0.0 ) * sin( 0.0 );		v.y = cos( 0.0 );		glNormal3fv( v );		glVertex3fv( center + v*radius );		for ( sl=0; sl<slices+1; sl++ )		{			a = float(sl)*off_R;			v.x = sin( a ) * sin( off_H );			v.z = cos( a ) * sin( off_H );			v.y = cos( off_H );			glNormal3fv( v );			glVertex3fv( center + v*radius );		}	glEnd();	glBegin( GL_TRIANGLE_FAN );		v.x = sin( 0.0 ) * sin( M_PI );		v.z = cos( 0.0 ) * sin( M_PI );		v.y = cos( M_PI );		glNormal3fv( v );		glVertex3fv( center + v*radius );		for ( sl=slices; sl>=0; sl-- )		{			a = float(sl)*off_R;			v.x = sin( a ) * sin( M_PI-off_H );			v.z = cos( a ) * sin( M_PI-off_H );			v.y = cos( M_PI-off_H );			glNormal3fv( v );			glVertex3fv( center + v*radius );		}	glEnd();	for ( st=1; st<stacks-1; st++ )	{		b = float(st)*off_H;		glBegin( GL_QUAD_STRIP );		for ( sl=0; sl<slices+1; sl++ )		{			a = float(sl)*off_R;			v.x = sin( a ) * sin( b );			v.z = cos( a ) * sin( b );			v.y = cos( b );			glNormal3fv( v );			glVertex3fv( center + v*radius );			v.x = sin( a ) * sin( b+off_H );			v.z = cos( a ) * sin( b+off_H );			v.y = cos( b+off_H );			glNormal3fv( v );			glVertex3fv( center + v*radius );		}		glEnd();	}}

Share on other sites
@Thaumaturge, thanks for the compliment! Im planning a simple 'risk' style strategy game, played out on a galactic map, with star systems instead of provinces, and real-time battles. I ended up with the space battle engine kinda by accident, i was aiming to make a scrolling shoot-em-up to begin with :)

@zedz, that code will be very useful, thankyou!

[Edited by - Daft_ Panzer on May 9, 2007 9:11:48 PM]

Share on other sites
It looks really cool. I like it!

pew pew :]

Create an account

Register a new account

• Forum Statistics

• Total Topics
627726
• Total Posts
2978816

• 10
• 9
• 21
• 14
• 12