Search code examples
iphoneopengl-estouchblender

Iphone + OpenGL ES + Blender Model: Rotation by Touch


I'd like to have a 3d object inside an iPhone UIView that can be rotated by using the touching events (swipe with a finger maybe). Where shall I start looking at? I guess OpenGL ES might be useful to do this, but I know nothing about it and I do not wanat to go deep inside OpenGL Programming ( studiying physics, rotations, quaternions etc) so maybe that is not what I need. I can create very basic 3d models in Blender so I'd like to use those in the app (I saw there are scripts that can parse and convert obj files in arrays of vertexes etc) Shall I rely upon a graphic engine like Irrlicht? Any suggestion is welcomed


Solution

  • That is something I've done a few months ago. A friend that is a proper Objective-C developer said I should try the SIO2 engine.

    Tutorial2 covers exactly what you are after.

    alt text
    (source: sio2interactive.com)

    Basically you build your scene in Blender and there is an exporter to get that in the SIO2 Game Engine on the IPhone, how awesome is that ? :)

    To break it down:

    1. Open up the xcodeproject from Tutorial02
    2. Open up Blender (with a mesh)
    3. Run the Exporter(select the TextEditor in a Window, open sio2_exporter.py from SIO2_SDK/exporter and run)
    4. Select your mesh and hit export. You could backup tutorial02.sio and export a new one.
    5. In template.mm find the templateScreenTouchMove() method (towards the bottom) and update the mesh name

    e.g. change

    SIO2object *_SIO2object = ( SIO2object * )sio2ResourceGetObject( sio2->_SIO2resource,
                                                                             "object/Suzanne" );
    

    to

    SIO2object *_SIO2object = ( SIO2object * )sio2ResourceGetObject( sio2->_SIO2resource,
                                                                             "object/YourMeshName" );
    

    It's all explained in the video tutorial as well.

    Good luck!