Tuesday, October 05, 2010

EarthBrowser on the iPhone/iPad/iPod Touch

It is hard to believe that I haven't posted to this blog for over a year. I'm not dead and neither is EarthBrowser. After a long hiatus where I've gained valuable skills (and salary) I have begun work on a new version of EarthBrowser. Working nights and weekends when possible.

Progress is coming along quite nicely since I am generating so much realtime content already however I have no release date yet. It's fun writing the shaders and being able to do coordinate projections right in the graphics hardware. I have to say that the limitations of the iOS are actually a blessing. Being able to focus on a small core set of features rather than trying to create the be-all software product is fun. It works amazingly fast on my iPhone 4 but the iPad is proving to be a bit slower than I'd like. I think it's a fill rate problem due to the large screen area.

Anyway, here's a screen shot:



If anyone still reads this old blog, please post your thoughts, wishes or any constructive ideas for what you'd like in the iPhone version of EarthBrowser. Now is the time to get your wishes out in the open.

Thursday, May 14, 2009

Zoltar Available on iTunes



Actually it's been available for about a week now but Apple didn't list it. I've run into a big problem with the iTunes store that a lot of other developers have been having. The result is that I've only had a few downloads, and Zoltar is much higher quality than most apps I see out there.

I hate to ask, but for anyone who follows this blog and has an iPhone, please go to the iTunes store and give Zoltar a great review. I'll buy you a beer the next time I see you!

SQLite C++ wrapper, so you don't have to

SQLite is great. It is small, fast and easy to set up. However, if you are writing software that needs it, you're in for a bit of learning. You will need to learn what API calls to make and when to make them, usually by going over example code and using trial and error. I am introducing an open source SQLite C++ wrapper that will allow you to use the database without having to learn the SQLite API. It may save you several days of work.

The wrapper is just two C++ files, has a MIT style license and is platform independent. You will still need to link in SQLite 3.0 and learn the quirky SQLite SQL syntax.

You can download it here.

Creating a database and table
#include "sdsqlite.h"

void create_db(void)
{
sd::sqlite database("mydb.db");
database << "create table if not exists work (first_name text, last_name text, hours real)";
}


Database insertion
#include "sdsqlite.h"

struct work_data { char* first; char* last; float hours; };

work_data wdata[] = {
{"Joe", "Smith", 2.5},
...
};

void insert_rows(void)
{
try
{
sd::sqlite database("mydb.db"); // open the db with the table already created

sd::sql insert_query(database); // build an sql query
insert_query << "insert into work (first_name, last_name, hours) VALUES(?, ?, ?)";

database << "begin transaction";// create a transaction for speed

// insert data (sdsqlite will auto-detect data type and execure query)
for(int i=0;i<sizeof(wdata)/sizeof(work_data);++i)
insert_query << wdata[i].first << wdata[i].last << wdata[i].hours;

database << "commit transaction";// complete transaction
}
catch(sd::db_error& err)
{
// do something with error
}
}


Database extraction
#include "sdsqlite.h"

void extract_name(const std::string& name)
{
try
{
sd::sqlite database("mydb.db"); // open the db with the table already created

// select all names that begin with the contents of the "name" variable
sd::sql selquery(database);
selquery << "select first_name, last_name, hours from work where first_name like ?" << name+"%";

// extract the matching rows
float hours;
std::string first, last;
while(selquery.step())
{
selquery >> first >> last >> hours;

// do something with the data
}
}
catch(sd::db_error& err)
{
// do something with error
}
}

Thursday, April 30, 2009

Zoltar the iPhone Fortune Teller

I've been taking a break from EarthBrowser for the past couple of months and working on an iPhone app. The result is Zoltar the Fortune Teller.

Apple is now reviewing it for release in the iTunes store. I've heard it takes anywhere from a couple of days to several weeks if they don't send it back for fixes. Hopefully it will be available in the next week or so. I'll do another post when it is up.


You select a card from one of five categories and Zoltar will do a divination on his magic crystal ball. He then will speak your fortune to you from a set of over 100 fortunes based in part on the minor arcana of the Tarot deck. You can rotate him around and zoom in close with a swipe or pinch on the iPhone screen. I created the music and am the voice of Zoltar and put some spooky echo effects so it sounds pretty cool.

It was a really fun project which allowed me to test the limits of the iPhone hardware. The model of Zoltar was created by my cousin in 3d Studio Max and has over 10,000 polygons. Even so it renders at about 30 frames per second which is really good for such a small processor.

The 3d game engine that powers EarthBrowser was originally ported from C++/OpenGL into ActionScript. Since then I have made many improvements and I've re-ported it back to C++. Have I said lately how much I like OpenGL since I don't have to write my own 3d graphics library like I do in Flash? I built bindings into the Lua scripting language for ease of development. Lua has a strange syntax but it is lightweight and fast and gets the job done.

Thursday, March 12, 2009

iPhone OS 3.0

Engadget is reporting that version 3.0 of the iPhone OS will be announced on March 17th.

I'm excited to hear what is going to come out in the new OS, but rumors are that there will be a micropayments model, which if true will be huge. However it seems to me that typing in your iTunes password for each micropayment would be a bit too unpleasant.

Wednesday, March 11, 2009

iPhone vs. Flash Player smackdown

Developing for the closed iPhone ecosystem is similar in many ways to Flash development. The graphics capabilities alone make it a superior platform. It doesn't have to be that way. I'm proposing three bold moves that would enable Flash to extend it's current lead in the RIA space and attract even more developers to the platform.

1) Explicit 3D graphics card support
Adobe can sandbox it all they like, but access to native high speed 3D rendering is one of the things that is making the iPhone such a hot platform. All that is really needed is to be able to pass on projection matrices, interleaved vertex buffer data, lighting and material settings to a graphics card and let it do it's thing. Make it detectable so developers can have a fallback if it's not available. Instantly web games become 1000% more possible.

2) A Javascript bridge a mile wide
ExternalInterface can get you where you need to go, with a lot of effort. Can you make it easier for us Adobe? I've taken the FABridge code, fixed some bugs (try passing the string \" from JS), and enabled the EarthBrowser plugin to be completely scriptable in Javascript. If Adobe could sit a few people down and nail down support for all browsers (including using VBScript to fake property getters and setters in IE7) then you could in effect create any Flash app completely in Javascript. This would open up a whole new world of possibilities for developers to create on the fly code that wouldn't have to be precompiled into a SWF. This would be HUGE.

3) An app store like iTunes
Along with great hardware, sleek design and serious developer tools the iPhone has a way for developers to monetize their creations. Adobe should do this for AIR apps and Flash plugins. Make a marketplace of website widgets and AIR apps that can be purchased for a few bucks. I have to administer my own servers and integrate a purchasing system with credit card companies, renew and manage a https certificates and deal with a lot of technical support not directly related to my software. It is a very small percentage of developers that are willing and able to spend the kind of time and money that it takes in order to sell stuff online. Apple has managed to create a system that does all of the heavy lifting of e-commerce and takes a healthy 30% cut for itself, but it's worth every percentage point.

Adobe has a spectacular platform that has a lot of room to grow. Flash market penetration is unreal and it is time for Adobe to get out of their overly cautious mindset and really create something new to help us developers create. Hire me, I'll direct the development.

Tuesday, March 03, 2009

Turned down for Where 2.0

I'm a little disappointed that my Where 2.0 proposal was rejected. I thought that demonstrating a virtual globe that supports KML and Shapefiles, can do coordinate projections on large datasets and be completely customized with Javascript and embedded on any website would be somewhat interesting. I find it interesting.

They have some interesting talks planned to be sure, I suppose if I were a sponsoring corporation they might have taken me more seriously. At least they offered me a 25% discount on the $1000+ registration fee to attend, but I don't think I'll take them up on that.

Oh well, back to my iPhone app that has nothing to do with geospatial.

Tuesday, February 10, 2009

C++ vs AS3

I've been working on an iPhone app for the past week or so and I'm pretty happy to be coding in C++ again I must say. C++ is not perfect by any means, in fact strong binding is a constant thorn in my side after the free and easy ways of Actionscript. Here are a few pros and cons that immediately stood out in moving between the two.

    Pro C++:
  • Variable declaration ("int x" is much better than "var x:int")
  • Enums
  • Templates in general and template meta-programming specifically
  • #defines and conditional compilation
  • Speed of execution

    Pro Actionscript 3:
  • Dynamic typing
  • Static constants of any type
  • Built in associative arrays
  • Built in UTF8 string support
  • Size of compiled code
  • Platform neutrality


In general I prefer C++. Perhaps because it's closer to the hardware and more things are possible, but you really have to know what you are doing to not spin your wheels too much. I *really* miss built in associative arrays and the awesome set of standard objects available in Flash however.

Tuesday, February 03, 2009

New KML extensions?

There appears to be a few new KML extensions with the new Google Earth 5.0 release. As someone who has to keep up with my own implementation of the KML standard, this is of great interest to me. The new extensions seem to mostly be geared toward creating animated tours, a laudable goal. I think that is a great improvement in providing the ability for everyone to create more eye candy using GE. For some reason they just added a new namespace "gx" rather than putting out a new version of the spec. I guess this makes sense since the core functionality didn't change much and they can roll the new elements into the main spec in a future version.

The <gx:TimeSpan> and <gx:TimeStamp> tags are what most interest me. The spec quotes that they are merely copies of their standard KML namesakes, but that they "allow for the inclusion of time values in AbstractViews" and "Time values are used to control historical imagery, sunlight, and visibility of time-stamped Features". I don't know why they had to add copies in a different namespace when they could have just allowed the non gx versions to be included in the <Camera> and <LookAt> tags. What I think this all means is that you can now control the timeline of visible features using the <Camera> tag. A huge improvement. however I've spent a year or two going down the road of trying to create dynamic animations using static control values to hardwired algorithms. It will get you down the road a little ways, but it is a totally inflexible and brittle way of defining 3D animation.

I am a little disappointed that they didn't include time coordinates as I suggested last summer. I think that I mentioned at the time that I had no interest in spending time getting that feature through the appropriate committees to make it happen, but I think that at this point I probably would, even though I have less time available now. The time coordinates I proposed, based on modified julian date, are tremendously useful.

As an example, the new EarthBrowser Site Tracker uses them to define the animated visitor hits. Basically each visitor hit looks like this:
<Placemark>
<name>...</name>
<LineString>
<coordinates>coord0 coord1 coord2 ...</coordinates>
<ebr:time>mjd0 mjd1 mjd2 ...</ebr:time>
<ebr:fade>.0625</ebr:fade>
</LineString>
</Placemark>


The interesting parts are the <ebr:time> and <ebr:fade> tags. What they specify are the modified julian date time value at which each coordinate in the LineString occurs. This provides an easy way to animate a single placemark by using linear interpolation to calculate intermediate locations for smooth animation and also provides the ability to show a cool time based fade effect. The <ebr:fade> specifies that after 1.5 hours the line trace should fade. I use these two KML extensions with the Satellite orbits in the latest version of EarthBrowser and also in the site tracker tool. To do something roughly equivalent in current KML, you would have to provide thousands of Placemarks each with their own TimeSpan and geometry, there would be no smooth animation or fade effect and it would take many megabytes for each placemark. With these two simple extensions I can display some really interesting features with effects in a single placemark with a very small footprint. If anyone from the OGC or Google is interested in contacting me about helping these extensions get through to the next spec, please post a comment or send me an email.

Interesting EarthBrowser Site Tracker discoveries

Last week I released the EarthBrowser Site Tracker, a free tool that gives an animated 3D global view of traffic to any website. I've been monitoring my own site traffic with it and have noticed some very interesting trends about my site, and perhaps some insight into the people who visit. It seems that I get slightly more European visitors than US visitors. Perhaps that is because EarthBrowser is in about 15 different languages and a lot of software is only in English. More people seem to visit a few hours after daybreak, perhaps when they get to their jobs, but in EuropeI've noticed that there seems to be a burst of visitors about an hour after nightfall.

The code was pretty simple and written in roughly 100 lines of Javascript which basically puts up the time slider, zoom scroller and loads the data file. I have some plans on improving the actual analysis and visualization of the data. I'd like to do trends such as visitors per country, browser language preferences, top countries and states and other fairly simple breakdowns of generic statistical data. But that will have to wait for a month or so, as will the open Javascript/Flex EarthBrowser API.

I am learning yet another new platform to program on. I got myself an iPod Touch, which is like an iPhone without the phone. I've just started porting some of my OpenGL framework from a mothballed version of EarthBrowser to OpenGL ES for a couple of new projects, one I'm doing as a contract. The new apps are really cool and a lot of people are going to love them. I'm not so impressed with most of the iPhone apps I've seen so far sadly, Google Earth is by far the best. Perhaps it is just hard to find good apps when there are tens of thousands out there, hopefully mine will be compelling enough to get some attention.