Home > Articles > Programming > Graphic Programming

  • Print
  • + Share This
Like this article? We recommend

Moving Bullet to iOS

Now that everything works on Mac OS X, the next step is to get relevant portions of Bullet working for iOS. Most of Bullet's demonstration applications are ill-suited for iOS, but the core engine features work without modification.

Create a new Xcode project by choosing File > New > New Project. Select the iOS Single View Application project template shown in Figure 7. Other project templates for iOS can be used, but stick with the relatively simple Single View Application for this tutorial.

Figure 7 Xcode project templates

Next, name your new project. Figure 8 shows a Product Name=Physics, Company Identifier=P, and Class Prefix=P. You can use any name and prefix you want. Be sure to save the new project inside the bullet-2.80-rev2531 folder. This tutorial assumes Use Storyboard and Use Automatic Reference Counting options are checked, as shown in Figure 8.

Figure 8 Xcode options for a new iOS application

Add pertinent Bullet source code to your new project. It's possible to build Bullet as an iOS static library and include just the compiled libraries in your new project, but it's simpler for this example to just add Bullet source code. Use Xcode's File > Add Files to Physics menu item. If you named your product something other than "Physics," the menu item will display your product's name. Figure 9 shows Bullet folders: BulletCollision, BulletDynamics, and LinearMath. They are added to the Xcode "Physics" product. Make sure the option Copy Items to Destination Group's Folder (If Needed) is not checked.

Figure 9 Adding Bullet source code to the Xcode project

Some of the files within the BulletCollision, BulletDynamics, and LinearMath folders just added are not relevant or compatible with iOS. Delete references to any extra files by selecting them in Xcode and pressing the Delete or Backspace key on the keyboard. The Xcode project should look like Figure 10 when you have the correct files.

Figure 10 Bullet folders added to the Xcode project

Select the Build Settings for the project as shown in Figure 11, and add the $(SRCROOT)/../src to the Header Search Paths setting. This setting is necessary for Xcode to find Bullet header files.

Figure 11 Add $(SRCROOT)/../src to Xcode's Header Search Paths setting

Press the Run button in Xcode, and a new iOS application including Bullet physics will be generated. You should see a plain white screen in the iPhone simulator or on your iOS device. The new application doesn't call any physics functions or draw anything yet. It's normal to see 11 compiler warnings generated from Bullet source code at this stage.

  • + Share This
  • 🔖 Save To Your Account