I have what seems a simple problem that is driving me up the wall.. if
anyone out there has some suggestions I would really appreciate it.
I am using JOGL and would like to create a pseudo-atmosphere on a
planet.
My planet is a texture mapped sphere and looks fine.
My "atmosphere" is a nother sphere slightly larger than the planet
sphere.
My plan was to texture map the INSIDE of the atmosphere sphere with a
cloud texture.. therefore when I am on the ground and look up I see
blue sky and clouds.
I have managed to texture map the clouds on to the sphere.. however
when ever I "enter" that sphere I can not see the inside of the
sphere... and hence no textures... everything only appears on the
outside of the sphere.
I have tried all combinations of culling, clockwise/counter clockwise
faces, depth tests on and off, Quadric orientation and modes.. but
nothing seems to help.. all I manage to do is change what happens on
the outside of the sphere... nothing I seem to do shows the inside of
the sphere...
Help!
Cheers
Mark
turn off culling, make sire you are using FRONT_AND_BACK gl.glMaterial.
glusphere may force culling, I don't know.
jbw
glDisable(GL_CULL_FACE)
--
<\___/>
/ O O \
\_____/ FTB. Remove my socks for email address.
Thanks for those answers.. however I have tried all of them and
they're not making any difference to the internals of my sphere.
The code I have at the moment is:
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glDisable(GL.GL_DEPTH_TEST);
double radius = dc.getGlobe().getEquatorialRadius()+2000000;
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
glu.gluQuadricOrientation(quadric,GLU.GLU_INSIDE);
texture.bind();
gl.glFrontFace(GL.GL_CW);
glu.gluQuadricTexture(quadric,true);
gl.glDisable(GL.GL_CULL_FACE);
glu.gluSphere(quadric,radius,300,300);
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glDisable(GL.GL_TEXTURE_2D);
gl.glFrontFace(GL.GL_CCW);
This is held in a display list.. which I wouldn't have thought would
make much difference...
Cheers
Mark
sphere = gluNewQuadric();
gluQuadricTexture(sphere, GL_TRUE);
gluQuadricOrientation(sphere, GLU_INSIDE);
CULL_FACE shouldn't be the problem.
I also think there is a way that you can have it be both inside and
outside. (don't quote me on that, you might have to draw 2 spheres)
Hope this helps
glDisable(GL_DEPTH_TEST);
glPushMatrix();
glTranslatef(x, y, z);
glRotatef(-90, 1, 0, 0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 15);
gluSphere(sphere, 80, 10, 10);
glDisable(GL_TEXTURE_2D);
glPopMatrix();
glEnable(GL_DEPTH_TEST);
I don't know if this will help because it looks like you are doing
basically same thing. (Not sure if function order will matter or not)
The only other thing I can think to give you is my opengl environment
set up.
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glDisable (GL_LIGHTING);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glDisable(GL_DITHER);
Thanks for the feedback. I think the problem may be external to my
code.. I'm writing my OpenGL layer inside another OpenGL application..
and whilst everything else is behaving normally I have a sneaking
suspicion that the parent app is mucking the OpenGL states
somewhere..
Cheers
Mark
It's all about putting the right texture coordinates on the vertices that
make up the sphere.
for 2d textures with [i,j] coordinates at every vertex;
The "poles" -- all the vertices there -- will have a J texture coordinate
of [0 or 1] (approximately -- you need to deal with texel centering).
The vertices around the "equator" will have a J of 0.5
Get it ?
The X coordinates start a approximately 0 at the "prime meridian" and go all
the way aroudn the globe to approx 1 at the end (duplicating the coordinates
at the "prime meridian").
I'll leave edge effects and correct centering ot texels to you.
You should easily be able to use automatic texture coordinate generation, if
your project permits it.
jbw
JBW, I have figured out what I needed, and can easily map an image to
my sphere now. The weird thing is, I can't get the sphere to rotate
though, I always look at the sphere from a distance, i.e. I keep it at
origin, and translate back from it.
I looked at some samples, is this the correct logic to rotate a sphere
in JOGL?
I use an Animator that calls display continually
in display method.....
z++;
gl.glEnable(GL_TEXTURE_GEN_S);
gl.glEnable(GL_TEXTURE_GEN_T);
gl.glBindTexture(.....)
gl.glPushMatrix();
gl.glRotatef(z,1.0f,0.0f,0.0f);
I print out z, and it is continually incrementing, but the sphere
never actually rotates, any reason why it is not rotating?
thanks
JB