Loading 3D model in iOS

2019-05-03 07:52发布

I'm creating a game application from scratch with xcode for iOS, and I've use the OpenGL Game projet template to create mine.

I've searched a lot in the past few days, but I can't find any tutorials or example as to how I would load 3D model (via .obj files) in my application. I've found some documentation on loading them onto an app with a console script, but I need to do it programmatically.

Any help would be very appreciated

Also, my 3D models are created using blender

5条回答
时光不老,我们不散
2楼-- · 2019-05-03 07:58

I recommend to use an Engine (like isgl3d, nineveh, Cocos3D, ...) for creating a 3D game, it will be hard if you use Opengl for a start.

Note: you can search for a list of game engine to choose the suitable one for you game, cause there is a lot of game engine, open-source or paid engine.

查看更多
Melony?
3楼-- · 2019-05-03 08:00

The future will be here momentarily — SceneKit, available in OS X since v10.8, will be in iOS 8. It can build and render a scene with COLLADA (.DAE) models directly. No need for third-party tools or code, nothing complicated to learn.

Apple's documentation is pretty good but if you prefer then other tutorials are available.

查看更多
Ridiculous、
4楼-- · 2019-05-03 08:19

Obj files are simple to parse and are well described on wikipedia. You should be able to load them in one or 2 hours. But if you want to load the materials you need to invest some more time in your engine and into loading the obj file.

查看更多
何必那么认真
5楼-- · 2019-05-03 08:21

OpensceneGraph has support for iOS and a lot of prebuilt code which can help you develop the game. It supports loading OBJ models.

查看更多
贼婆χ
6楼-- · 2019-05-03 08:21

You can download the zip file from here and then run ./obj2opengl.pl 3DModel.obj in terminal .It will give you 3DModel.h file as output.

You need to use glDrawArrays instead of glDrawElements as the .h file contains array.

查看更多
登录 后发表回答