
over the last week ive been playing around with openFrameworks on the iphone and getting a handle on openGL ES for a work project. its been lots of fun and suprisingly tricky to find decent resources, especially when mapping textures and geo coordinates onto a sphere. ive developed a nice basic example which i think is a good start for anyone tackling an earth application on the iphone using openFrameworks or even working with Objective C.
the example contains code for drawing a sphere in openGL ES and giving it an earth texture which is provided in the source. theres a Trackball class which allows you to intuitively rotate the textured sphere and a CurveHop class which draws a curved ribbon from location to location as it hops along on the surface of the earth. theres a cool little trick you can do in google maps to get the latitude and longitude of any location, so you can add it into the curve hop chain. just search for a location in google maps and copy the following code into your address bar,
javascript:void(prompt(”,gApplication.getMap().getCenter()));
this will bring up a popup with the latitude and longitude of the center of the map.
download the source code.
Hi Julapy,
This is an excellent resource that you have posted! I tried compiling this for iPhone OS 3.0+, and there is just one problem: the earth texture does not load. :(
Do you know why this would be happening? Would it be possible for you to take a look at this and post an updated version for 3.0+?
I figured it out!
Things to change:
ofTexture *earthMapTexture;
earthMapTexture = &earthMap.getTextureReference();
earthMapTexture->bind();
earthMapTexture->unbind();
Woohoo!
I feel like I’m spamming your blog… :P
To get the latitudes and longitudes working again, I changed these lines:
lat *= 1;
lat += 90;
lon *= 1;
lon -= 90;
I also reflipped the image (so North America is on the left). :)