Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import Blender 3D animation to iPhone OpenGL ES?

I am trying to do animations on iPhone using OpenGL ES. I am able to do the animation in Blender 3D software. I can export as a .obj file from Blender to OpenGL and it works on iPhone.

But I am not able to export my animation work from Blender 3D to OpenGL. Can anyone please help me to solve this?

like image 859
quint Avatar asked Jan 23 '10 09:01

quint


People also ask

How does Blender use OpenGL?

OpenGL rendering uses the 3D View's drawing for quick preview renders. This allows you to inspect your animatic (for object movements, alternate angles, etc.). This can also be used to preview your animations – in the event your scene is too complex for your system to play back in real-time in the 3D View.

How do I export a 3D model from Blender to Unity?

To import Blender assets into Unity, click Assets > Import New Asset on the Unity menu bar, then find and open your . blend file. To use Maya files in Unity, click Assets > Import New Asset on the Unity menu bar, and look for and open Maya's .


2 Answers

If you have a look at this article by Jeff LaMarche, you'll find a blender script that will output a 3D model to a C header file. There's also a followup article that improves upon the aforementioned script.

After you've run the script, it's as simple as including the header in your source, and passing the array of vertices through your drawing function. Ideally you'd want a method of loading arbitrary model files at runtime, but for prototyping this method is the simplest to implement.

Seeing as you already have a method of importing models (obj) then the above may not apply. However, the advantage of using a blender script is that you can then modify the script to suit your own needs, perhaps also exporting bone information or model keyframes.

like image 158
Ian Nafiri Avatar answered Sep 23 '22 18:09

Ian Nafiri


Well first off, I wouldn't recommend .obj for this purpose since the obj file format doesn't support animation, only static 3D models. So you'll need to export the animation data as a separate file that you load at the same time as the obj.

Which file format I would recommend depends on what exactly your animations are. I don't remember off the top of my head what file formats Blender supports, but as I recall it does not export Collada files with animation, which would be the most general recommendation. Other options would be md2 for character animations, or 3ds for simple "rigid objects moving around" animations. I think Blender's FBX exporter will work, although that file format may be too complicated for your needs.


That said, and assuming you only need simple rigid object movements, you could use .obj for the 3D model shapes and then write a simple Python script to export a file from Blender that has at the keyframes listed, with the frame, position, and rotation for each keyframe. Then load that data in your code and play back those keyframes on the 3D model.

like image 43
jhocking Avatar answered Sep 25 '22 18:09

jhocking