Help me: Textured earth globe using JOGL

My quest is simple: draw a textured sphere representing earth using JOGL.

After getting NetBeans 6.5 and JOGL to work in my Ubuntu 9.04 I started porting this C++ code to JOGL.

Thanks to google and freenode#java, here I am:


http://img37.imageshack.us/img37/851/001aftersomejavaproblem.th.png

Its a bit weird. I need to figure why the globe is messed up. I’m pretty sure has to do with math part of the code.

You can download current code here (netbeans project).

Help appreciated.

in glGlobe.createSphere you are building a QUAD_STRIP, and you render it as a TRIANGLE_STRIP

even the quad strip is wrong, as in the screenshot it is clear that the radius of the sphere is not equal for each vertex.

further, in your quad (vertices A, B, C, D), you calculate it in such a way that A==C and B==D, only the texcoords are different. so it wouldn’t even be visible. it is only visible now, because you make the GPU render it as a triangle-strip.

I truly fail to grasp your calculation method. It can only be wrong. I’d rewrite it from scratch.

Thank you very much for taking your time to review!

As you can see I ported it from a C++ code. It was even messier. I added it some OOP.

I agree with you, if I plan to get anywhere with that code I’d better rewrite the math.

Today night I’ll try refactoring the code and I’ll post my improve here.

Thanks allot Riven!

Coool, how did yoo do that?:wink:
I used gluQuadrics to do that…
Generally its an advanced task, therefore, i’m not sure where on your opengl knowledge level you are:
here, this is my code to do that, i’m pretty sure, there are more sophisticated possibilities to do that…Have fun to experiment…
You also can use the mouse to rotate the spere and use the mous buttons to move the lightsource (sun)…
Please ignore too those outcommented code for shaders. etc. etc. Also please keep in mind to look for nice textures. I found them at:
http://planetpixelemporium.com/planets.html
Also nasa.gov is a good site.

Please find attached the jogl code in txt file

Good luck,
Elnormeo

hi bruno,
thank you for the great howto. Is it ok for you when I link to your blog entry? :wink:

[edit] btw you are dzoned