Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

How do I view OBJ files on my iPhone?

3D Model Viewer – AR View is a 3D model viewer for iOS devices (iPhone and iPad) that can easily open files such as 3DS, OBJ, DAE, Blend, and STL, and you can even import files from iCloud.


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, I will tell you how to export the model for Blender, same works for 3D Max and Maya).
  2. Cocos3D game engine.
  3. PVRGeoPOD blender extension from Imagination Technology to convert blender model to format that Cocos3D understand. You can see that the link downloads an installer file which in turns downloads the entire SDK. I can't see an easy way to download the blender extension 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 game framework. Important think to note here is that, Cocos2D 2.x version is already there and stable. But Cocos3D works with Cocos2d 1.x version only.

    When you unzip the source you downloaded you will find a README file inside 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. After installation, you will get a nice Cocos3D project template in XCode.

  4. Add PVRGeoPOD extension to Blender.

    This requires some explanation. When you run the PVRGeoPOD installer, a screen shows what and what features need to be installed. 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), you need to add the PVRGeoPOD AddOn to blender. You can find the PVRGeoPOD.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 the path to this folder.
    • Find the blender add-on files inside the PVRGeoPOD folder, in your installation path. When you see files like libPVRGeoPOD.dylib and PVRGeoPODScript.py and 2 QTfiles, stop there as this is the location. Copy these 4 files and paste them in blender add on folder.
    • Now open blender, choose Preferences, find Add-On tab, search and find PVRGeoPOD extension and enable it by clicking the checkbox 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 these models as .POD files which Cocos3D understands.

    If you are using other 3D designing tools like Maya, 3D Max, this PVRGeoPOD extension can be added to them also. Just see the PDF I mentioned 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, add that texture to your project also.
  4. The template project itself contains a HelloWorld.POD file, you can replace that line with your .POD file so that your model will be visible.

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

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


I'm having a play with iPhone development for a bit of fun and bought Beginning iPhone Development by Dave Mark and Jeff LaMarche (ISBN13: 978-1-4302-1626-1) and am enjoying working through the chapters. I have a Win32 Delphi background with a bit of .NET and so Objective C is very new to me.

One of the chapters is on OpenGL and Quartz which may be of interest to you. I've haven't got that far yet so I can't really comment on how useful it will be for yourself but the writing style is very accessible and it's paced well (for me anyway).

The initial chapters explain exactly how to get up an running with a good introduction to Xcode and InterfaceBuilder.


For anything on iOS 8 or later, the answer is SceneKit. SceneKit will render Collada (DAE) files. Any decent modelling package (eg Cheetah, Blender) should export a DAE file - it's a documented portable format in XML (though xCode compiles them into binary format to save space).