Want to display a 3D model on the iPhone: how to get started? [closed] Want to display a 3D model on the iPhone: how to get started? [closed] ios ios

Want to display a 3D model on the iPhone: how to get started? [closed]


Once again, if I may plug my own work, I have written a post about the things I've learned from developing an OpenGL ES application on the iPhone. That application, Molecules (referred to by frankodwyer), is open source and I have a writeup on some of the other tricky issues I ran into while developing it. The application generates 3-D models and lets you rotate and scale them with your fingers, which sounds close to your needs. You can download the code, compile it, and run it on your desktop in a matter of a few minutes. If you join the iPhone Developer Program, you can install it on your device.

When it comes to object loading, Bill Dudney is working on a Wavefront OBJ loader for the iPhone that might be able to take in your Blender files, should they be exportable in that format. I haven't done much texture work on the iPhone yet, but it sounds like his example has that working now.

Overall, I find that learning by example and by jumping into development of some small, targeted applications (that you may never release) are what works for me. Try tweaking the examples listed above and see what happens. You should be able to read through the Objective-C code in those examples and start to get a feel for what they're doing.

Even though Hillegass's book (the third edition just came out and is up-to-date) focuses on the Mac, the Cocoa fundamentals he teaches are still relevant for the iPhone. The MVC design pattern serves you just as well on the iPhone as the Mac. I actually deviated from that pattern in a few places within Molecules, and I regret that decision because those sections of the application became a mess. The book is an easy read and well worth your time.


You should probably start with some simpler iphone apps/tutorials, just to get your footing on obj-c and xcode etc.

For that, I recommend the pragmatic programmer's iphone book, which has enough information to get started (I started with no knowledge of xcode, obj-c, iphone or mac and got to a working app fairly fast, using mainly this). However I should add that I come from a fairly good background in C/C++ and Java.

For your particular project, perhaps take a look at this answer which refers to an open source 3D app that you can look at and get tips from.


This is an ancient thread and I am terribly late. But still I am going to post my 2 pence here.

A Sneak Preview

Before I get in to the beast, this is my setup.

I use

  1. Blender to create 3D models. (You can use Maya or 3D Max, Iwill tell you how to export the model for Blender, same works for 3DMax and Maya).
  2. Cocos3D game engine.
  3. PVRGeoPOD blender extension from Imagination Technology toconvert blender model to format that Cocos3D understand. You can seethat the link downloads an installer file which in turns downloadsthe entire SDK. I can't see an easy way to download the blenderextension alone.

So if you are not intending to use Cocos3D, you can skip this answer and run for your money.

Initial Setup

  1. Install blender.

    I am not going to embarrass you by going in to details.

  2. Download Cocos3D..

    When I type this, the current version is 0.7.2.

  3. Download Cocos2D.

    Cocos3D is written on top of popular Cocos2D, a popular 2D gameframework. Important think to note here is that, Cocos2D 2.x versionis already there and stable. But Cocos3D works with Cocos2d 1.xversion only.

    When you unzip the source you downloaded you will find a README fileinside and it specifically says,

    PLEASE NOTE THAT cocos3d 0.7.2 IS NOT COMPATIBLE WITH cocos2d 2.x. BE SURE TO DOWNLOAD cocos2d 1.x FOR USE WITH cocos3d.(emphasis mine)

    The README file clearly tells the installation procedure. Afterinstallation, you will get a nice Cocos3D project template in XCode.

  4. Add PVRGeoPOD extension to Blender.

    This requires some explanation. When you run the PVRGeoPODinstaller, a screen shows what and what features need to beinstalled. I only selected

    • PVRGeoPOD - To convert my models in my .blend file to .POD format that Cocos3D understands

    • PVRShaman - you can view the model inside .POD using this tool.

    enter image description here

    You can install other tools in the list, but I only used these two.

    Now after the installation process (which may take some time), youneed to add the PVRGeoPOD AddOn to blender. You can find thePVRGeoPOD.UserManual.PDF file in the just installed folder, which also contains below information.

    • Find Blender Add-On folder, you can open blender python console and run command bpy.utils.script_paths("addons") to see thepath to this folder.
    • Find the blender add-on files inside the PVRGeoPOD folder, in your installation path. When you see files likelibPVRGeoPOD.dylib and PVRGeoPODScript.py and 2 QTfiles, stop there as this is the location. Copy these 4 files and paste them inblender add on folder.
    • Now open blender, choose Preferences, find Add-On tab, search and find PVRGeoPOD extension and enable it by clicking thecheckbox on the right.
    • Now Quit and restart blender, if needed, and select file->export and see if there is an option called PVRGeoPOD(.pod/.h/.cpp),if yes,you are successful.

    Now you can create models in blender, and export thesemodels as .POD files which Cocos3D understands.

    If you are using other 3D designing tools like Maya, 3D Max, thisPVRGeoPOD extension can be added to them also. Just see the PDF Imentioned above.

Using in project

  1. Step by step procedure is given below.

    Create your model in blender (.blend) and export it as .POD file.When you export I normally select following options

    • Primitive Type - Indexed Triangle List
    • Material tab - Check Export Material Option

    and rest I left it as default.

  2. Create a new project in XCode, choose Cocos3D template.
  3. Add the .POD files to your project. If yours a textured model, addthat texture to your project also.
  4. The template project itself contains a HelloWorld.POD file, youcan replace that line with your .POD file so that your model will bevisible.

    [self addContentFromPODFile: @"YourPODFileName.pod"];

Now you have your first 3D model visible in iOS device.