Create a 3D Flight Simulator App for iOS and Android – Project Export

In this tutorial series, we will create a flight simulator application using ShiVa3D Suite. In order to build this application, we will cover all the topics necessary for creating 3D games, educational applications, and novelty 3D apps. In this tutorial, the 4th and final installment, we will focus on exporting the application for multiple platforms.

Part 3 of this series had focused on adding the code and unit testing the end product. In part 4, the last installment of the series, we will export the application from the ShiVa Editor and import into the ShiVa Authoring Tool. Then, we will explain how to convert the application into a platform specific executable via the ShiVa Authoring Tool. The platforms we will consider are Android, iPad, and iPhone. We will give screen images of the Simulator from actual devices used for testing, a Motorola Droid phone with Android OS 2.2, an iPad2 with iOS 4.3, and an iPod Touch with iOS 4.3. Finally, in the 'Concluding Remarks', we will give a conclusion to the series.


Also available in this series:

  1. Create a 3D Flight Simulator App for iOS and Android - Theoretical Overview
  2. Create a 3D Flight Simulator App for iOS and Android - Environment Creation
  3. Create a 3D Flight Simulator App for iOS and Android - Simulator Programming
  4. Create a 3D Flight Simulator App for iOS and Android – Project Export

Exporting The Game

Currently, development of the Simulator game has been completed. We will now export the Simulator for two different platforms for authoring: iOS, for deployment into iPad and iPhone/iPod Touch devices, and Android OS, for deployment into Android powered devices.

Export For iOS

In Data Explorer, under the Games folder, select Simulator. From the right click menu, select Export Game (If asked to save anything with the game, select Yes).


From the Export dialog, let the Export field name be "Simulator". Make sure the Local folder checkbox is checked, and choose a local folder to export the game. Also, check the Runtime package (.stk) checkbox and choose iOS for the corresponding platform.


Press "Export" to export the game. It may take awhile to complete the export. Once completed, you will see a confirmation box as follows:


Export For Android

This is similar to exporting for iOS except that the platform for Runtime package must be selected as Android.



The ShiVa Authoring Tool

So far, we have developed the Simulator without writing any code specific to iOS or Android platforms. We will now use the ShiVa Authoring tool to convert the Simulator into three different applications, one for Android, one for iPhone/iPod touch, and one for iPad.

The Android Platform

Bring up the ShiVa Authoring Tool. Select the Android tab. Press on the arrow under 'Or get started now...'.


Step 1 of the Authoring Tool is displayed. For 'Application pack', select from your file system the Simulator.stk file exported from ShiVa Editor for Android. For 'Icon', select the flight-48-48.png which is part of the source archive accompanying this series. For 'Startup splashscreen', select the flight-480-800.png which is also part of the source archive accompanying this article. Observe that the ShiVa Authoring Tool displays a preview of the image files specified in 'Icon' and 'Startup splashscreen' selections. Press 'Step 2: Authoring' atop the screen.


Step 2 of the Authoring Tool is displayed. Here, we will create an Android executable file that can be directly installed in an Android device. Select 'Authoring type' as 'APK Package' (If you want an Eclipse project to be created instead of an executable, select 'Project' instead. The Project option has not been tested in this series). For the 'Bundle identifier', enter com.shiva3d.simulator. Let 'Version' and 'Version code' remain as 1.0.0 and 1, respectively. Press on 'Step 3: Build' atop the screen.


Step 3 of the Authoring Tool is displayed. Select 'Build type' as 'Development'. The 'Use OpenGLES 1.1' checkbox should be unchecked (We have not tested the build with that checkbox checked). Since we would like to install the Simulator into our Android device as part of the build, we've checked the 'Install on connected device' checkbox. For that option to work, you must have completed the steps in 'Prepare The Android Device For Installation' below. If the 'Install on connected device' checkbox is not checked, the Authoring Tool will create the Android executable for the Simulator application in the 'Output folder', which can be installed later on using the adb tool in Android.

Leave 'Audio backend' as 'Default'. Select 'Minimum OS support' as 'Android 2.2 (API level: 8)'.


Define an output folder for the Authoring Tool to store the files it generates during the build process. Let 'Custom post build script' selection remain as a 'No script' option. Press the Build button.


It will take awhile to complete the build. Once the build is completed, you will see a confirmation in the console stating that the build completed successfully.


If you have selected the 'Install on connected device' option, at this point the Simulator application has been installed on the connected device. Regardless of whether that option has been checked or not, an Android executable called Simulator-debug.apk has been created in the output folder you defined in Step 3.

Prepare The Android Device For Installation

If you want the Shiva 3D Authoring Tool to install the Simulator in the Android device as part of the build, you need to prepare the device for installation. Firstly, in the Application settings, check 'Unknown sources', as shown below.


Then, in the development options of your device, check 'USB debugging' as shown below.


Also, make sure that your device is connected to your development machine via a USB cable (note that when you connect a particular Android device to your Windows PC for the first time, Windows OS will install the appropriate device driver in your computer. You may need to point the Add Hardware Wizard to the location of Android SDK installation folder for the wizard to find a suitable driver).

Simulator Screens For the Android Device

The Simulator has been deployed in a Motorola Droid phone with Android 2.2 OS. The figure below shows the shortcut for Simulator in the Android start menu (the startup icon is the image file named flight-48-48.png used above in the authoring tool).


The following is a screenshot of the Simulator on an Android device.


The iPad Platform

We will now use the ShiVa Authoring Tool to create the Simulator application for deployment onto an iPad device. Bring up the ShiVa Authoring Tool. Select the iPad tab. Press on the arrow under 'Or get started now...'.


Step 1 of the Authoring Tool is displayed. For 'Application pack', select from your file system the Simulator.stk file exported from ShiVa Editor for iOS. For 'Icon', select the flight-72-72.png which is part of the source archive accompanying this series. For 'Startup splashscreen', select the flight-768-1024.png which is also part of the source archive accompanying this series. Observe that the ShiVa Authoring Tool displays a preview of the image files specified in the 'Icon' and 'Startup splashscreen' selections. Press 'Step 2: Authoring' atop the screen.


Step 2 of the Authoring Tool is displayed. Here, we will create an Xcode project that can be used for building and installing the application on an iPad device. Select 'Authoring type' as 'Project'. For 'Bundle identifier', enter com.shiva3d.simulator. For 'Provision profile' provide the development provisioning profile from the Apple Provisioning Portal. For 'Signing identity' provide the developer (or organization) name in the keychain associated with the certificate in your Mac OS development machine. Let 'Version' be 1.0.0. Press on 'Step 3: Build' atop the screen.


Step 3 of the Authoring Tool is displayed. Select 'Development' as the 'Build type'. The 'Use OpenGLES 1.1' checkbox should be unchecked (We have not tested the build with that checkbox checked). Provide an output folder for the Authoring Tool to create an Xcode project folder. For example, we define the output folder to be /Users/cocoderkatz/Desktop/tmpiPad. Then, the Authoring Tool will create a folder named /Users/cocoderkatz/Desktop/tmpiPad/Simulator_iPad.s3dxproj and copy the Xcode project files/folders under that folder. Do not change other options. Press the Build button.


Once the build has completed, you will see a message in the console that the Authoring tool has created an Xcode project folder and copied the related files into that folder. Now, you can use xCode to build and run the Simulator application on an iPad device as you would normally do with other Xcode projects.


Simulator Screens On An iPad 2 Device

The Simulator has been deployed on an iPad 2 device with iOS 4.3. The figure below shows the shortcut for the Simulator on an iPad 2 start menu (The startup icon is the image file named flight-72-72.png used above in the authoring tool).


The following is a screenshot of the game on an iPad 2 device.


The iPhone Platform

We will now use the ShiVa Authoring Tool to create the Simulator application for deployment onto an iPhone/iPod touch device. Bring up the ShiVa Authoring Tool. Select the iPhone tab. Press on the arrow under 'Or get started now...'.


Step 1 of the Authoring Tool is displayed. For 'Application pack', select from your file system the Simulator.stk file exported from ShiVa Editor for iOS. For 'Icon', select the flight-114-114.png which is part of the source archive accompanying this series. For 'Startup splashscreen', select the flight-640-960.png which is also part of the source archive accompanying this series. Observe that ShiVa Authoring Tool displays a preview of the image files specified in 'Icon' and 'Startup splashscreen' selections. Press 'Step 2: Authoring' atop the screen.


Step 2 of the Authoring Tool is displayed. Here, we will create an Xcode project that can be used for building and installing the application on your iPhone or iPod touch device. Set the 'Authoring type' to 'Project'. For 'Bundle identifier', enter com.shiva3d.simulator. For 'Provision profile' provide the development provisioning profile from Apple Provisioning Portal. For 'Signing identity' provide the developer (or organization) name in the keychain associated with the certificate in your Mac OS development machine. Let 'Version' be 1.0.0. Press on 'Step 3: Build 'atop the screen.


Step 3 of the Authoring Tool is displayed. Select 'Development' as the 'Build type'. The 'Use OpenGLES 1.1' checkbox should be unchecked (We have not tested the build with that checkbox checked).


Provide an output folder for the Authoring Tool to create an Xcode project folder. For example, we define the output folder to be /Users/cocoderkatz/Desktop/tmp. Then, the Authoring Tool will create a folder named /Users/cocoderkatz/Desktop/tmp/Simulator_iPhone.s3dxproj and copy the Xcode project files/folders under that folder. Do not change other options. Press the Build button.


Once the build has completed, you will see a message in the console that the Authoring tool has created an Xcode project folder and copied the related files in that folder. Now, you can use Xcode to build and run the Simulator application in an iPhone or iPod Touch device as you would normally do with other Xcode projects.


Simulator Screens On iPod Touch Devices

The Simulator has been deployed in an iPod touch with iOS 4.3. The figure below shows the shortcut for Simulator in iPod touch start menu. The startup icon is the image file named flight-114-114.png used above in the authoring tool.


The following is a screenshot of the game on an iPod touch.



Concluding Remarks

In this series, we developed a simple flight simulator using the ShiVa 3D Suite and deployed it on Android and iOS devices. The main development tools we used are the ShiVa Editor and the ShiVa Authoring Tool. The ShiVa Editor is used to develop a 3D game in a platform independent manner. It allows the developer to create 3D graphics of the application and the corresponding code. The output from the ShiVa Editor is a platform specific export file, e.g. one for Android OS or one for iOS. The export file from the ShiVa Editor is then imported into the ShiVa Authoring Tool to generate an executable file or a project file for the specific platform. For Android OS, we generated an Android executable file using the ShiVa Authoring Tool. For iPad2 and iPhone/iPod, we generated corresponding Xcode projects using the ShiVa Authoring Tool.

A product suite to develop cross platform applications without writing any platform specific code, ShiVa 3D Suite offers great help to those who are interested in creating 3D applications for iOS and Android devices. Visit ShiVa3D Suite for additional platforms supported by the ShiVa Editor and the ShiVa Authoring Tool.

Below we give additional comments on the Simulator application we have discussed in this series.

Terrain Creation

While developing the Simulator, we introduced various basic features of the terrain creation functionality in ShiVa Editor. More sophisticated visual effects can be added to a terrain. For example, you could add snow to mountains, define different textures such as rock, soil, vegetation or water. However, some of those visual effects will require importing image files representing the particular terrain texture. In other words, you will need resources created outside the ShiVa 3D Suite.

The terrain we created has limited dimensions. It requires special techniques to develop a terrain that never ends, i.e., one that has infinite dimensions. For a discussion in that regard see http://www.stonetrip.com/developer/forum/viewtopic.php?f=39&t=20668.

Units And Variables

The notion of a distance unit in Shiva3D Editor is not an absolute concept. It should be interpreted relative to the application and the particular device where the application is going to run. In the Simulator, three important parameters related to the distance unit are

  • size of the terrain, which is 4,096 x 4,096 units;
  • initial altitude of the plane, which is 50 units, defined as the initial Y axis coordinate,
  • the variable V, representing the speed, whose value is 0.25.

From a review of the move() function where we utilize the variable V, it is easy to see that the plane travels at 0.25 units per frame. (Recall that the function move() is called at every frame.) If you deploy the application in a device that displays 20 frames/second, the simulated speed will be 18,000 units/hour. Now, let us assume that one distance unit corresponds to 30 feet. Then, keeping in mind that 1 mile = 5,280 feet:

  • size of the terrain is approximately 23.3 miles (= 4,096 units x 30 feet x 1 mile / 5,280 feet)
  • initial altitude of the plane is 1,500 feet (= 50 units x 30 feet)
  • the speed of the plane is approximately 102.3 miles/hour (= 18,000 units/hour x 30 feet x 1 mile / 5,280 feet)

We could have assumed that one distance unit corresponds to 50 feet. Then, the size of the terrain, initial altitude of the plane and the speed of the plane would change accordingly. We are simply commenting on the fact that a distance unit is not an absolute physical value. It is a parameter input to various functions in our Simulator game. What really matters is whether the user will perceive the simulated dynamics as sensible or not.

Other two variables that are important in terms of creating a realistic flight experience are dP and dR (see pitch() and bank() above). The dP is used to control the rate of pitch whereas dR is used to control rate of roll and rate of turn. We have determined the final values for V, dP and dR by trial and error after deploying the Simulator in the target devices several times.

We finally note that the current values for V, dP and dR in the code listings above appeared to be a better fit for iPad 2 and iPod touch devices than Motorola Droid. This is probably because Motorola Droid, being an early example of Android phones, has a slower CPU than the other two. With the revised values set as follows, we have observed more realistic dynamics in Motorola Droid.

  • V = 0.75 (instead of 0.25)
  • dP = 0.2 (instead of 0.04)
  • dR = 0.15 (instead of 0.05)

How To Extend The Simulator

The interested reader could extend the Simulator to make it more appealing. Some ideas are listed below in increasing order of complexity.

  • Add sound to the game that plays when a particular maneuver starts. A good starting point is the tutorial in Chapter 7 of Shando's Shiva Book.
  • Add landmarks to the terrain for the plane to slalom around. For each missed target assign a penalty point and display it on the screen.
  • Add a 3D plane model to follow in front of the camera. Assign the control buttons to maneuver that plane. Let the thumb actions control the camera. User will navigate the plane and the camera so that the plane will never get out of sight.
Tags:

Comments

Related Articles