3D engines for iOS Development

I’m evaluating several different 3d engines for our planned iOS space combat game Torchships.

I found good overviews at Never Read Passively, Open Source iPhone game engine comparison, and The Commercial iPhone Game Engine Comparison (3D and 2D).

This week I’m digging more into Unity and cocos3d to get a better understanding of the pros and cons. Unity looks very nice but I’m not sure I want to go with a non-iOS-native solution.

Here is the list of 3D engines I’ve looked at so far…

<>

UDK – Unreal Development Kit for iOS – PC & iOS

The same toolset used to make Gears of War and Infinity Blade.

+ Beautiful graphics

+ Industry Standard, high performance

+ Completely integrated development system

- Development on PC only

- proprietary scripting

Unity 3D – web, flash, iOS, Android, PC & Mac, Wii, PS3, xBox 360

Very popular 3d engine that supports a large number of platforms.

+Large developer base and very active community

+Very nice 3d Graphics, physics, and particle effects.

+Integrated editor and asset pipeline

+Largest number of platforms available

+Javascript or C#

+Mac native development

-Not a native iOS app, all new iOS features may not be available right away

Marmalade

Engine to create of richer apps and games on iOS, Android and other platforms.

+based on c++

-based on c++ :)

Shiva3d

3D game engine with a graphical editor to create applications and games for Windows, MacOS, Linux, iPhone, iPad, Android, BlackBerry QNX, WebOS, Marmalade and Wii

SIO2

An OpenGLES based cross-platform 2D and 3D game engine for iOS, Android, MacOS and Windows

cocos3d

An extension to cocos2d. A sophisticated 3D application development framework for the iOS platform.

+open source

+based on and can integrate with the very powerful and popular cocos2d library

+native iOS

ISGL 3D

iSGL3D (iOS Scene Graph Library) is a 3D framework for the iPhone, iPad and iPod touch written in Objective-C, enabling the creativity of developers to flourish in a 3D world without the complexities of OpenGL.

+based on OpenGL

+iOS native

-author is not actively supporting, looking for new contributors

Web2PY , Google App Engine, and DatastoreTimeoutException

While web2py runs great on the Google App Engine there are several gotchas that can cause a lot of headache if you aren’t aware of them. [Note to readers - this post assumes an advanced understanding of web2py and python.]

Google App Engine will throw a timeout error (DatastoreTimeoutException ) if your web2py function takes too long to execute. This can happen with a long database update or query. The average time to trigger a timeout appears to be about 30 seconds.

One approach to resolve this, if you can’t refactor your query or update operation to guarantee it will stay under 30 seconds or 1,000 records, is to create a progress display page that periodically calls a web2py function to incrementally perform the operation you are attempting.

The example I’ll use is a fairly complex report that works against a large number of records that can take several minutes to execute.

We have a summary_report view that allows the user to choose multiple filter options (year, school, etc). On submit the controller summary_reports is called, the request.vars from the user selections are saved as session variables and the view summary_report_display is called. The variable session.summary_m is our chunk size for our query, you can increase it to speed up the report but going too high can cause the process to hit the 30 second limit.


@auth.requires_login()
def summary_reports():

    if request.vars.teacher_select:

        #stores running values from report generator
        session.dictGraphVariables={}

        #user selections
        session.year_select=request.vars.year_select
        session.school_select=request.vars.school_select
        session.class_select=request.vars.class_select
        session.teacher_select=request.vars.teacher_select
        session.semester_select=request.vars.semester_select
        session.observer_select=request.vars.observer_select
        session.datestart=request.vars.datestart
        session.dateend=request.vars.dateend

        session.includearchive=request.vars.includearchive

        #used in the partial query
        session.summary_i=0
        session.summary_m=300
        session.summary_break=0

        #counter for number of report results
        session.summary_overallcount=0

        redirect(URL('summary_report_display'))

    return dict()

Our summary_report_display view has a javascript function defined that calls our web2py function get_progress_on_summary_report every 3 seconds, the get_progress_on_summary_report does the heavy lifting.


{{extend 'layout.html'}}</pre>
<h1>Generating Reports</h1>
<h2>This may take a while if you have a lot of walkthroughs - but you can monitor progress below...</h2>
<pre></pre>
<div id="progress"></div>
<div id="summary_report_show"></div>
<pre>

Here is the code in the web2py controller for summary_report_display that sets up the progress bar display and the javascript call to get_progress_on_summary_report every 3 seconds.

progress = DIV(_id="progress")
wrapper = DIV(progress,_style="width:400px;")
summary_report_show = DIV(_id="summary_report_show")

@auth.requires_login()
def summary_report_display():

    page.include("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js")
    page.include("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-darkness/jquery-ui.css")
    callback = js.call_function(get_progress_on_summary_report)
    page.ready(jq(progress).progressbar( dict(value=request.now.second) )() )
    page.ready(js.timer(callback,3000))
    return dict(wrapper=wrapper)

The get_progress_on_summary_report function in the web2py controller does most of the work.


def get_progress_on_summary_report():

    if session.summary_break==0:

        queries=[]

        #base query includes all walkthroughs
        queries.append(db.t_walkthrough.id>0)

        #build the query list based on user selections

        #if user hasn't selected 'All' for an individual search/filter term, then add to the query
        if session.school_select!='All':
            queries.append(db.t_walkthrough.school==int(session.school_select))

        if session.semester_select!='All':
            queries.append(db.t_walkthrough.semester==session.semester_select)

        if session.year_select!='All':
            queries.append(db.t_walkthrough.f_year==session.year_select)

        if session.class_select!='All':
            queries.append(db.t_walkthrough.t_class==int(session.class_select))

        if session.teacher_select!='All':
            queries.append(db.t_walkthrough.teacher==int(session.teacher_select))

        if session.observer_select!='All':
            queries.append(db.t_walkthrough.observer==int(session.observer_select))

        #handle start / end date if user entered same
        if len(session.datestart)>0:
            date_object = datetime.datetime.strptime(str(session.datestart), '%Y-%m-%d')
            queries.append(db.t_walkthrough.f_date>=date_object)

        if len(session.dateend)>0:
            date_objectEnd = datetime.datetime.strptime(str(session.dateend), '%Y-%m-%d')
            queries.append(db.t_walkthrough.f_date
        #create query from list
        summary_report_query = reduce(lambda a,b:(a&b),queries)

        rows = db(summary_report_query).select(limitby=(session.summary_i*session.summary_m,(session.summary_i+1)*session.summary_m))

        for r in rows:

            # do something with r
            session.summary_overallcount+=1
            list_walkthrough_result=db(db.t_walkthrough_result.walkthrough==r.id).select()
            for w_record_result in list_walkthrough_result:
                if not type(w_record_result.f_result) is NoneType:
                    if w_record_result.f_result==None:
                        #do nothing
                        testvalue='none'
                    else:
                        if w_record_result.f_result in session.dictGraphVariables:
                            session.dictGraphVariables[w_record_result.f_result]+=1.0
                        else:
                            session.dictGraphVariables[w_record_result.f_result]=1.0

        if len(rows)
<a href="summary_reports_complete">Click Here to View Graphs</a>'
            else:
                return_value='Report generation complete - there are ' + str(session.summary_overallcount) + ' results.

'

            return jq(summary_report_show).html(return_value)()
        else:
            return

The core of the the iterative process is the query below, it pulls a chunk of rows (size defined by summary_m) each cycle.

rows = db(summary_report_query).select(limitby=(session.summary_i*session.summary_m,(session.summary_i+1)*session.summary_m))

This performs our operation in chunks, once there are no more rows the function changes state and then returns a link to the summary_report_show view page which will parse the results and present them to the user, if no results are produced then the operation tells the user.

This approach will let you perform queries or db updates against an very large set of records without triggering the timeout.

Using Parse to add a backend to your iOS app

We’ve had to write over a dozen server back ends for iOS applications. There is a lot of manual work involved, no matter what platform you choose (we’ve used Google App engine or custom php solutions based on Joomla). There is the code and database development on the server side, plus a lot of code on the iOS side to handle the calls to the server, error handling, etc. It’s a royal pain and something we’d like to avoid in the future if possible.

Parse is a new service that simplifies back end development for iOS immensely – it can take literally minutes to add a simple server side component to your iOS app.

Pricing is free in Beta and looks very reasonable going forward as well.

We recently used Parse to add server functionality to an iOS Math application for YourTeacher.com. The app stores user preferences to a simple Parse object. Adding Parse to our project, testing, and deploying took less than an hour. Performance is good – besides being able to save and retrieve standard dictionary objects you can use Parse to store and manipulate remote files and geo location objects.

They have a very good overview of the integration process for iOS, plus the API is available as a REST service and for the Android as well.

Highly Recommended

iOS Game – Torchships

One of the very nice new features of iOS 5 from Apple is that GameCenter will handle all of the mechanics and hosting for multiplayer turn based games. This creates an opportunity to build a very feature-rich multiplayer game without a lot of infrastructure costs.

Accordingly we’re going to design and develop a 3d turn based space combat game for the iPhone and iPad with realistic physics. The game will be ad-supported and free to download and play. We will release rapid iterations and add features as we go….

  • Using iSGL3D for the 3d graphics.
  • 4 gameplay modes – tutorial/training, hotseat (same device), peer to peer (wifi/bluetooth via gamekit), game center hosted
  • Realistic Newtonian physics.
  • Weapons include – gamma ray lasers, missiles, and kinetic launchers.
  • Terrain – terran planets, moons, asteroid fields, ring systems, dust and debris clouds.

Working title for the game is Torchships.

If you’re interested in following our progress follow this blog (see the right hand pane of this page to sign up)

If you’d like to help beta-test Torchships then please sign up at our TestFlight page – you will need an iPad, iPhone, or next generation iTouch to participate.

Functional Spec for Mason News iOS App

This is the functional specification for the update to our Mason County News iOS application. The format is based on an excellent template created by Joel Spolsky.

Overview
Mason County News is an iOS universal application that runs on an iPad or iPhone.  It is designed to pull the latest Mason County news from the Mason TX County News web site at http://www.masoncountynews.com/ via the paper’s RSS feed.

The results of the feed will be stored in local core data, the articles and pictures from the feed will also be downloaded and stored locally, with extra html and other data removed for easier viewing when offline. All updates from the site will be running as background threads….
This spec is not, by any stretch of the imagination, complete. All of the wording will need to be revised several times before it is finalized. The graphics and layout of the screens is shown here merely to illustrate the underlying functionality. The actual look and feel will be developed over time with the input of graphics designers and iterative user feedback.

Scenarios
In designing products, it helps to imagine a few real life stories of how actual (stereotypical) people would use them. We’ll look at one scenario…
Scenario 1: Mike.
Mike is a busy executive who was born and grew up in Mason, TX but now lives in Paris France. He still has friends and relatives in Mason and likes to keep up to date on what is going on back in his home town. He reads news on the go on his iPhone or sometimes at home or in his private jet on his iPad. He also likes to share articles via MMM or email with his beautiful French girlfriend so she can practice her English. He likes to read articles offline as well as online.

Non Goals
This version will not support the following features:

  • different languages

Mason News Flowchart
We’ll have time later to go into mind-numbing detail, but for now, let’s look at a quick flowchart of the service so you get the big picture. This flowchart is not complete, but it does give you the right idea for the “storyboard” of using Mason News on your iOS device.

Flowchart

Screen by Screen Specification
Mason New consists of quite a few different screens. Most screens will follow a standard format, with a look and feel to be designed in the future by a graphic designer. This document is more concerned with the functionality and the interaction design, not the exact look and layout.
All screens are created in the XCode interface builder. (The single exception is the Splash Screen, which is created using GIMP).
Each screen in Mason News is known by a canonical name which will always appear, in this document, with an underline, so you know we’re referring to a screen by name, for example, Home Page.

Default Splash
An image of the Mason TX courthouse or other appropriate image – just is displayed during initial load of application, and when first load of rss feed on first start of app.

Home Page
Displayed when app load is complete – looks like below (shows list of all newsitems in the database, sorted by most recent on top) – some items may  not have pictures

<>
Technical Note – 
All updates are in the background – starts empty

Read Article
Picking an article – will load it in the viewer – view will be scrollable down and will contain links as appropriate, also pictures (using  uiwebview)
While reading an article you can share it. share via twitter, facebook, mmm, email, google +, etc

Share Article

About App
Simple page with picture same as splash – then credits and info about Mason and the newspaper

Blogs We Read

Seth Godin
Has written thirteen books that have been translated into more than thirty languages. Every one has been a bestseller. He writes about the post-industrial revolution, the way ideas spread, marketing, quitting, leadership and most of all, changing everything.

A smart bear
Startups + Marketing + Geekery
From someone who’s been there: Jason Cohen, founder of Smart Bear Software.

TechCrunch
-lately embroiled in controversery over being acquired by AOL and the exit of founder Michael Arrington – but still a great source for tech and investing news – especially focused on silicon valley startups

Slashdot
No intro needed – tagline says it all ‘news for nerds, stuff that matters’

iOS developer tips
Tips and tricks for iOS developers building iPhone and iPad applications.

Mason County News
Our own backyard.

Bootstrap Austin
A community in the Austin Entrepreneur Scene.

Mark Cuban’s blog

The Bottom Feeder
Jeff Vogel has been an independent game developer since 1994.

4 Hour Work Week
The blog of Tim Ferriss

Using XCode 4 with GitHub

Git is a distributed source control system (like subversion) – still not sure what it is and if you need it? Take a look at this crash course.

GitHub is a web-based hosting service for software development projects that use the Git revision control system. GitHub offers both commercial plans and free accounts for open source projects.

This is how we set up Xcode 4 and GitHub to work together on the Mac for a new iOS (iPhone or iPad) project. We’re assuming Mac OS Version 10.6.8, Xcode version 4.02 and the latest version of Git.

  1. Register as a new user with GitHub. You can host public open source projects on GitHub for free – if you need private projects you will have to sign up for a paid plan.
  2. Follow GitHub set up steps 1 & 2.
  3. Create your new project in Xcode – check ‘create local git repository for this project’ within the wizard when asked.
  4. Create a README file and add it to the main directory of your Xcode 4 project.
  5. On GitHub create a new repository with the same name as your Xcode project (it doesn’t have to be same name but keeps things simpler).
  6. After creating the new repository (or ‘repo’) on GitHub – follow the ‘Existing Git Repo?’ directions on GitHub.
  7. Now as you make changes in your Xcode source code or project – you can commit them with the standard Xcode command – File -> Source Control -> Commit.
  8. After committing your changes you can push them to your remote repository on GitHub from the command line (from your Xcode project directory) using ‘git push -u origin master’.