想要在 iPhone 上显示 3D 模型:如何开始?
我想在 iPhone 上显示和旋转单个 3D 模型,最好是带纹理的。不需要放大和缩小,或者有背景,或者任何东西。
我有以下设备:
- iPhone
- MacBook
- iPhone SDK
- Blender
我的知识库:
- 我可以在各种 3D 程序中制作 3D 模型(我最喜欢使用 3D Studio Max,我曾经参加过该课程,但我用过其他)
- 多年前的过程编程常识(QuickBasic - 我老了!)
- 初学者通过简单的 Java 和 C# 教程获得的面向对象编程知识(Head Start C# 书和我妻子的介绍)使用 Java 的 OOP 课程)
- 我已经成功地显示了 3D 纹理模型并使用我从网上下载的 C# 教程旋转它(我不只是复制和粘贴,我基本上了解它是如何工作的)和 XNA 游戏开发库,在 Windows 上使用 Visual Studio。
我不知道的内容:
- 关于 Objective C 的很多
- 内容 关于 iPhone 显然使用的 OpenGL 或 OpenGL ES 的任何内容
- 关于 XCode 的任何内容
我的主要问题是我不知道从哪里开始!我发现的所有 iPhone 书籍似乎都是关于创建 GUI 应用程序,而不是 OpenGL 应用程序。我找到了一本 OpenGL 的书,但我不知道有多少(如果有的话)适用于 iPhone 开发。我发现 Objective C 语法有些令人困惑,奇怪的嵌套方法命名,诸如“id”之类没有意义的东西,以及我必须进行手动内存管理的可怕想法。
最好从哪里开始?我找不到任何关于此类事情的教程,但也许我的 Google-Fu 很弱。或者也许我应该从学习 Objective C 开始?我知道像 Aaron Hillgrass 这样的书,但我也读到它们已经过时了,并且大部分示例代码无法在 iPhone SDK 上运行,而且它似乎面向模型-视图-控制器范式,但它并不适用。似乎适合 3D 应用程序。
基本上我对我的第一步应该是什么感到困惑。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
再说一遍,如果我可以插入自己的作品,我已经写了一个这篇文章介绍了我在 iPhone 上开发 OpenGL ES 应用程序时学到的东西。该应用程序 Molecules (由 Frankodwyer 引用)是开源的,我有一个 writeup 一些我在开发过程中遇到的其他棘手问题。该应用程序生成 3D 模型,并允许您用手指旋转和缩放它们,这听起来很接近您的需求。您可以在几分钟内下载代码、编译并在桌面上运行它。如果您加入 iPhone 开发者计划,则可以将其安装在您的设备上。
在对象加载方面,Bill Dudney 正在研究 适用于 iPhone 的 Wavefront OBJ 加载器 可能能够在您的 Blender 中使用文件,是否可以以该格式导出。我还没有在 iPhone 上做太多纹理工作,但听起来他的例子现在已经可以工作了。
总的来说,我发现通过示例学习并直接开发一些小型的、有针对性的应用程序(您可能永远不会发布)对我来说很有效。尝试调整上面列出的示例,看看会发生什么。您应该能够通读这些示例中的 Objective-C 代码,并开始了解它们在做什么。
尽管 Hillegass 的书(第三版刚刚出版并且是最新的)主要针对 Mac,但他教授的 Cocoa 基础知识仍然与 iPhone 相关。 MVC 设计模式在 iPhone 上和在 Mac 上一样适用。事实上,我在 Molecules 中的一些地方偏离了这种模式,我对这个决定感到遗憾,因为应用程序的这些部分变得一团糟。这本书很容易阅读,非常值得您花时间。
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.
你可能应该从一些更简单的 iphone 应用程序/教程开始,只是为了让你在 obj-c 和 xcode 等方面站稳脚跟。
为此,我推荐实用程序员的 iphone 书,它有足够的信息来入门(我开始时对 obj-c 和 xcode 等一无所知) xcode、obj-c、iphone 或 mac,并且主要使用这个,相当快地获得了一个工作应用程序)。不过我应该补充一点,我有相当好的 C/C++ 和 Java 背景。
对于您的特定项目,也许可以看看这个答案,其中提到到一个开源 3D 应用程序,您可以查看该应用程序并从中获取提示。
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.
这是一条古老的线索,而我却迟到了。但我还是要把我的 2 便士贴在这里。
先睹为快
在我深入了解这头野兽之前,这是我的设置。
我使用
将告诉您如何导出 Blender 模型,同样适用于 3D
麦克斯和玛雅)。
将 Blender 模型转换为 Cocos3D 可以理解的格式。你可以看到
该链接会下载一个安装程序文件,该文件又会下载
整个SDK。我看不到下载搅拌机的简单方法
单独扩展。
因此,如果您不打算使用Cocos3D,您可以跳过这个答案并开始赚钱。
初始设置
安装blender。
我不会详细介绍让您难堪。
下载Cocos3D。。
当我输入此内容时,当前版本是 0.7.2。
下载 Cocos2D。
Cocos3D 是在流行的 Cocos2D(一种流行的 2D 游戏)之上编写的
框架。这里需要注意的重要一点是,Cocos2D 2.x 版本
已经存在并且稳定。但 Cocos3D 可以与 Cocos2d 1.x 一起使用
仅版本。
解压下载的源代码后,您会发现一个 README 文件
里面特别说,
<块引用>
请注意,cocos3d 0.7.2 与 cocos2d 2.x 不兼容。是
请务必下载 cocos2d 1.x 以与 cocos3d 一起使用。(强调我的)
README 文件清楚地说明了安装过程。后
安装后,您将在XCode中获得一个不错的Cocos3D项目模板。
将 PVRGeoPOD 扩展添加到 Blender。
这需要一些解释。当您运行 PVRGeoPOD 时
安装程序,屏幕显示需要什么以及需要什么功能
安装。我只选择了
PVRGeoPOD - 将 .blend 文件中的模型转换为 Cocos3D 可以理解的 .POD 格式
PVRShaman - 您可以使用此工具查看 .POD 内的模型。
你可以安装列表中的其他工具,但我只使用了这两个。
现在,安装过程结束后(可能需要一些时间),您
需要将 PVRGeoPOD AddOn 添加到搅拌机。您可以找到
刚刚安装的文件夹中的 PVRGeoPOD.UserManual.PDF 文件,其中还包含以下信息。
bpy.utils.script_paths("addons")
来查看此文件夹的路径。
libPVRGeoPOD.dylib 和 PVRGeoPODScript.py 和 2 个 QT 文件,停在那里,因为这是位置。复制这4个文件并粘贴到
搅拌机添加文件夹。
右侧的复选框。
如果是,那么你就成功了。
现在您可以在搅拌机中创建模型,并将其导出
模型为 Cocos3D 可以理解的 .POD 文件。
如果您使用其他 3D 设计工具,例如 Maya、3D Max,则此
PVRGeoPOD 扩展也可以添加到其中。只需查看 PDF 我
上面提到过。
在项目中使用
下面给出了分步过程。
在搅拌机 (.blend) 中创建模型并将其导出为 .POD 文件。
当你导出时我通常选择以下选项
其余的我将其保留为默认值。
该纹理也适用于您的项目。
模板项目本身包含一个HelloWorld.POD文件,您
可以用您的 .POD 文件替换该行,以便您的模型
可见的。
现在您的第一个 3D 模型在 iOS 设备中可见。
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
will tell you how to export the model for Blender, same works for 3D
Max and Maya).
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,
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.
bpy.utils.script_paths("addons")
to see thepath to this folder.
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.
checkbox on the right.
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
and rest I left it as default.
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.
Now you have your first 3D model visible in iOS device.
我正在尝试 iPhone 开发,并购买了 Dave Mark 和 Jeff LaMarche 编写的《Beginning iPhone Development》(ISBN13:978-1-4302-1626-1),并且很享受阅读这些章节的过程。我有 Win32 Delphi 背景和一点 .NET,所以 Objective C 对我来说非常陌生。
其中一章是关于 OpenGL 和 Quartz 的,您可能会感兴趣。我还没有做到这一点,所以我无法真正评论它对你自己有多大用处,但写作风格非常容易理解,而且节奏很好(无论如何对我来说)。
最初的章节通过对 Xcode 和 InterfaceBuilder 的良好介绍准确地解释了如何开始运行。
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.
对于 iOS 8 或更高版本上的任何内容,答案是 SceneKit。 SceneKit 将渲染 Collada (DAE) 文件。任何像样的建模包(例如 Cheetah、Blender)都应该导出 DAE 文件 - 它是 XML 中记录的可移植格式(尽管 xCode 将它们编译为二进制格式以节省空间)。
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).