How to use 3D models in Xcode (iPhone)? [duplicate] - iphone

Closed. This question needs to be more focused. It is not currently accepting answers.
Closed 3 years ago.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
I want to display and rotate a single 3D model, preferably textured, on the iPhone. Doesn't have to zoom in and out, or have a background, or anything.
I have the following:
an iPhone
a MacBook
the iPhone SDK
Blender
My knowledge base:
I can make 3D models in various 3D programs (I'm most comfortable with 3D Studio Max, which I once took a course on, but I've used others)
General knowledge of procedural programming from years ago (QuickBasic - I'm old!)
Beginner's knowledge of object-oriented programming from going through simple Java and C# tutorials (Head Start C# book and my wife's intro to OOP course that used Java)
I have managed to display a 3D textured model and spin it using a tutorial in C# I got off the net (I didn't just copy and paste, I understand basically how it works) and the XNA game development library, using Visual Studio on Windows.
What I do not know:
Much about Objective C
Anything about OpenGL or OpenGL ES, which the iPhone apparently uses
Anything about XCode
My main problem is that I don't know where to start! All the iPhone books I found seem to be about creating GUI applications, not OpenGL apps. I found an OpenGL book but I don't know how much, if any, applies to iPhone development. And I find the Objective C syntax somewhat confusing, with the weird nested method naming, things like "id" that don't make sense, and the scary thought that I have to do manual memory management.
Where is the best place to start? I couldn't find any tutorials for this sort of thing, but maybe my Google-Fu is weak. Or maybe I should start with learning Objective C? I know of books like Aaron Hillgrass', but I've also read that they are outdated and much of the sample code doesn't work on the iPhone SDK, plus it seems geared towards the Model-View-Controller paradigm which doesn't seem that suited for 3D apps.
Basically I'm confused about what my first steps should be.

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
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).
Cocos3D game engine.
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
Install blender.
I am not going to embarrass you by going in to details.
Download Cocos3D..
When I type this, the current version is 0.7.2.
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.
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.
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
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.
Create a new project in XCode, choose Cocos3D template.
Add the .POD files to your project. If yours a textured model, add
that texture to your project also.
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).

Related

Cocos2d for iPhone vs. Cocos2d-x [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have worked some with Cocos2d for iPhone and find it delightful. I am starting another project, and have stumbled across Cocos2d-x, a C++ port. I'm tempted by the notion of being able to (with consideration) build for multiple platforms at once. I'm equally comfortable with Obj-C and C++, and am not looking for comparisons between the two languages unless it's specifically related to working with Cocos2d.
Has anyone worked with both versions of the engine, and can you comment on specific pros and cons of the two? Is Cocos2d-x "finished"? Reliable?
The lure of multi-platform builds are a nightmare in disguise. Any web designer will tell you horror stories of trying to juggle IE with Firefox with Chrome with whatever at the same time. You will not suddenly earn more sales because you were able to launch on Android/iOS/etc on day one. More than likely, your attempts to multi-platform will restrict your app in ways that will kill it on all platforms. Your best bet is to start with one platform, finish that, then build for others. Your end product will thank you.
There are no pros/cons to Cocos2d-x unless you like C++ more than Obj-C.
I would agree that you should focus on developing for a single platform until you have a good solid product out there. However many a developer that does this after the fact realizes how much effort and additional cost is then needed to completely rewrite the game on a new platform. Would a little upfront thought you can minimize the need for rework and thus minimize your cost once you are ready to port your game. Android is too big of a market share to completely ignore it; in my mind Cocos2d-x is the way to go if you like Cocos2d.
I don't know about cocos2d-iphone but I do know about cocos2d-x.
Pros:
cocos2d-x uses C++ (well, not really a pro for some but this is a pro for me)
You can easily deploy to different platforms, assuming you've set it up correctly (see below)
It supports Lua and JavaScript, for an even easier coding
Cons:
cocos2d-x has little to no documentation. You would rely on the test projects and the API Reference. Thank god there are people like Nat Weiss who made learning easily available to users. (http://paralaxer.com/cocos2d-x-book/)
Setting up your project to work on every platform is a hassle. You'd have to be good at multiple IDEs as well as command line/terminal commands
Most of the scripts that come with the library to create new projects are not multi-platform, meaning, you still have to set it up individually for all platforms
Integrating third-party SDKs like Facebook, ads, and other stuff takes a lot of time since you'd have to implement them for every platform you are targetting
I am developing with cocos2d-x for iphone and it is working just fine for me. Only issue you may find is that the api is always slightly behind the cocos2d for iphone version. However api itself is reliable and a facsimile in most respects to the original.
If you're serious about porting to other platform even though you will try to succeed on a single platform first, cocos2d-x is the way to go, because you will not need to rewrite the gist of your code in some other language later (ie port from c++ to objc or from objc to c++).
I have worked with both Cocos2d and Cocos2d-X for iPhone development only (so far). I worked with Cocos2d for about 1.5 years and have moved on to Cocos2d-x in the last six months or so. At first, I was unwilling to move into Cocos2d-x because, in my opinion, it was still maturing. Coco2d 2.0 had come out with a lot of changes and I knew it was well deployed and tested. Coco2d-x seemed like it was still in flux. This has changed and I have decided to use Cocos2d-x for the duration, as long as it continues to be supported.
Both frameworks appear to work as advertised, in general, and give good performance for what I am working on (you can see some examples here).
I am comfortable with working in both the Object-C and C++ world. I don't know if I will ever port my "stuff" to Android, but it is nice to have the option.
However, the BIG deciding factor for me was reusability. I build lots of components and widgets that I reuse in other projects. If I developed for iOS only, Objective-C would be the way to go. But I work mostly in C++ and I don't want to have to recode all the ideas from one language to another every time I want to bring a tested tool out of the tool box.
I think this is going to ring true for any framework you choose to use for your development. If you have the choice, go with the option that will give you the best bang for your buck today, and down the road.
I am currently working on cocos2d-x and I am very happy with it. My advise would be to start the project on one Platform (I prefer IOS). And when you have successfully launched on one platform, start on another.
If your game becomes successful, at the end you have to launch on another platform too. So its best to plan ahead.
I would stick with Cocos2D-iphone. Focus on the product from the bigger community with a lot more resources. When you are ready to port, then use apportable to compile your app for android when it's done.

Mixing Unity generated code with Objective-C in iOS?

Is it possible to mix iOS code and interface elements with Unity generated iOS code?
For example if I am working with a game developer who is developing a game in Unity, could I take his xCode project (generated by Unity), and add interface elements which I code myself using Objective-C & Interface Builder etc?
From what I can see this isn't possible as everything is created via Unity.... but hopefully I am wrong...
Thanks!
You can even use 3rd party libraries in XCode and integrate them in the build process. After fiddling around with the right settings I wrote a blog entry about this:
iPhone & Unity3D: Integrating 3rd Party Static Libraries in Unity3D Generated XCode Projects
You should be able to generate Native plug ins to interact with the Unity code. You would need to write a wrapper though. Read more at: http://unity3d.com/support/documentation/Manual/Plugins.html
Read the part at iOS :)
I came across this general guide to working with Unity native plugins in OSX which was useful and is probably where you need to be looking for your answer, as Zophiel said
https://blog.reigndesign.com/blog/unity-native-plugins-os-x
You can just design a view and button to trigger the unity to run or stop, but models in unity can't be controlled using Obj-C, although unity has import to Xcode, it only import the start code, game scripts depending on the link libraries which couldn't be modified.
I think you can do it as the same way I probably has been working with Objective-C without any changes. For Unity's code generator preserves the native codes under Classes.
And furthermore there is an another way to do this which is called "Plug-in".
But I hope the developers in Unity find a better way seamlessly combined with Xcode as staffs in Apple usually does.
Combining IB and Unity's integrated editor would be better and more welcomed in future.
Possible yes. Advisable for beginner or intermediate level Devs? Probably not. The Unity project is generated and regenerated every time you push a build. Now I believe that if you use Append when you do builds that it should keep existing changes to the Xcode project... but 'should' is the operative word there. You may need to implement some sort of build system like Jeeves to keep the headaches to a minimum if you are trying to do this on a large project in which you for see a constant stream of updates from both the Unity side and the Xcode side.
Now if you're integrating code that is in it's own files and doesn't overlap or rewrite the code Unity has generated, then the Append feature is really going to work for you, but if you're deleting, altering, or adding code to any of the files that Unity generated then definitely use SVN or some other form of source control and snap shot before and after every new Unity recompile / Xcode generation.
Also, take a look in the Unity Asset store. Whatever functionality you are trying to home brew in Xcode can definitely be written in C# on Unity. Someone else may have already conquered the problem you're trying to solve and placed it in the asset store for $5.
Hope that helps.

Can you run a blender game on an iphone or droid?

I have an iPhone and am getting the Droid and was wondering if blender games can run on either of them. I have already made a game and want to be able to use it on my phone.
****UPDATE****
I was wrong, just recently android support has been added but it's brand spanking new so just know that android support would be considered beta quality if that, perhaps even alpha.
I can't believe no one has given this answer:
http://code.google.com/p/gamekit/
Supports the logic bricks/python scripts etc so basically you can just load up your packaged blend file and you're good to go.
there is actually a book on how to integrate blender into a iphone game development workflow. it uses sio2 for the game engine on the iphone. it might be worth to give it a shot.

Apple/iPhone Development IDE Preferences?

I'm going to do something I never thought I'd do... learn how to program for Apple hardware . After working in C, C++, C#, .NET, and even in the golden days of DOS (a little DOS4G/W memory extender in Borland Turbo-C, anyone?) and even as a kid, playing around with Atari 8-Bit Turbo-BASIC, I feel a little traitorous on multiple levels :) Anyway, I'm going to grad school, studying music full-time - it'll be the first time in years I won't have a full-time programming gig - and I thought it would be fun to pick-up some Objective-C in my free-time - and maybe a little extra pocket change (one can always hope :)
So, to the point of the post. I'm very used to Visual Studio, the designer, the XAML editor, the code-behind, blah blah blah. A friend pulled up X-Code on his little MacBook to show off how cool it's supposed to be. Sure, it has the same sorts of things as VS overall, but it seemed a little more scattered then I'd like. I'm sure once I got used to it, it would be fine, but I was just wondering if there are other good, free (or almost free)/or open-source editors out there for the Intel-based Apples that could also handle iPhone development. Or any tips on getting into xCode? I've just decided to do this, so I feel like I'm starting from scratch. I'm not slamming X-Code... I haven't really used it yet. I was just wondering what coders' preferences are.
Thanks for any advice!
There really is no alternative IDE on OS X for writing native applications. Some dislike the Xcode built-in editor, however. One very popular alternative is TextMate (non-free, but well worth the ~$50). Xcode can be configured to use your editor of choice for editing text files. Free alternatives include Emacs and Vim ports for OS X.
You can, of course, use the gcc toolchain without Xcode (e.g. using one of the Unix-style build systems such as Make). You can also use xcodebuild at the terminal command line to build an Xcode project without using the Xcode GUI at all (you'd be hard-pressed to configure and manage the project without the GUI, however). Combining these two, one could cobble together an IDE from e.g Eclipse to build an OS X app. iPhone would be harder since Xcode handles certificate signing etc. for you, but still possible. You would loose all of the nice Objective-C completion and documentation integration you get from Xcode, of course.
So, in summary, Xcode is pretty much the only game in town. It will undoubtedly take a while to get used to coming from VS. In particular, code generation is almost unheard of in the Cocoa world. When you feel yourself searching for those kind of tools, train yourself to try a different approach. Objective-C's late-binding combined with the power of NIB/XIB (bundles produced in Interface Builder that describe the UI of an app; XIB is a newer, version-control-friendly XML-based format that is automatically compiled into a NIB, the old-style format from NextStep days) makes code generation unnecessary.
For non-Cocoa/iPhone development, the ecosystem is naturally larger. Nokia has their own IDE for the Qt toolkit which can be used to write OS X (but not iPhone) apps. Eclipse can be used to write Java apps using any of the Java toolkits (including SWT and the Qt-Java framework, QtJambi).
For pure Windows-developer familiarity, there's also Mono which runs on OS X. MonoDevelop may run on OS X, but I'm not sure.
I think XCode is the most popular choice amongst Cocoa developers. I think the best thing you could do is go straight into writing apps and exploring.
http://cocoadevcentral.com/ - Has some great tutorials, they're also usually very screenshot friendly.
For pure ease XCode will be the way to go since it integrates with the iPhone simulator and Interface Builder. Also, when you want to deploy your app to an actual device XCode does the certificate installation and management. I don't have experience with any other IDE's for OSX though so I can't 100% answer your question. But, these are things you'll want to be aware of during your investigation.
Let us know what you find!

Game development on iPhone using Unity engine

Im very new to game development on the iPhone... And I have a question:
If I was to unity, how would that work... Would I use objective-c in unity? or is all of it like just click it, and add properties, no code (that may be a stupid question, but im just wondering)
And once your done with the unity app, does it automaticly complile an xcode file for you?
Im just wondering... Thanks
Unity provides it's own visual design environment, and scripting language support. The scripting is done with C#, Javascript, and Boo for all the platforms they support. You can test your apps on the iPhone.
You can download the trial on their website.
I have used Unity and worked with some of their people, here is what I can offer:
Unity is a visual editor and as mentioned by ManiacDev you can use C#, Javascript, and Boo.
You can do a lot without coding a line and it outputs a file for you to compile in xcode. That's pretty sweet. It is very much WYSIWYG - but for some that leaves a lot to be desired.
Examining this further:
If you did want to use your own Objective C classes and code and bring them into Unity this would require purchasing their Pro version. Personally - I wouldn't go the basic license for this one reason alone. If I want to use my own server or anything else I have already coded in other projects of course I would want to take advantage of the work I have already created and not rewrite more code in C# - for the iPhone this makes no sense at all considering the uniqueness of the device and the other possibilities that could be imagined when having full access to the SDK.
The other thing you might want to think about is that their logo will appear with the basic version - if you don't care and you want to use their tools - the basic version is a great entry point. I personally do not mind their logo at all but again not having the full SDK at my disposal is not a place I would like to be locked in when you want to see your full creative potential.
Hope this helps,
Matthew