2

I have installed Blender, compiled Jeff LaMarche’s Blender Objective-C Export Plugin and exported "MyImage.obj" as an Objective-C header file (GraphicsTypes.h) successfully.

Now I am trying to draw 3D shape from Blender exported Header file using OpenGL in iPhone.

This is the picture representation of MyImage.obj in Blender. I have pasted my Blender exported Objective-C header file below.

How can i draw the same 3D picture in Objective-C using the below code.

I am following this link to do the process. However i am unable to incorporate the model into my application.

I didn't find any tutorial to render the image using the below code (Blender exported Objective-C header).

I have tried the code with HelloGLKit OpenGL sample application . However it didn't draw any thing.

Any help on this issue is appreciated.

GraphicsTypes.h [Blender exported Objective-C header]

//If not using MC3D, change 1 to 0 to add needed types
#if 1
    #import "MC3DTypes.h"
#else
    struct texCoord
    {
        GLfloat     u;
        GLfloat     v;
    };
    typedef struct texCoord texCoord;
    typedef texCoord* texCoordPtr;

    typedef struct vec2 vec2;
    typedef vec2* vec2Ptr;

    struct vec3
    {
        GLfloat x;
        GLfloat y;
        GLfloat z;
    };

    typedef struct vec3 vec3;
    typedef vec3* vec3Ptr;

    struct vec4
    {
        GLfloat x;
        GLfloat y;
        GLfloat z;
        GLfloat w;
        };

    typedef struct vec4 vec4;
    typedef vec4* vec4Ptr;

#endif

struct vertexData
{
    vec3        vertex;
    vec3        normal;
}
typedef struct vertexData vertexData;
typedef vertexData* vertexDataPtr;


static const vertexData MeshVertexData[] = {
    {/*v:*/{1.000000, -1.000000, -1.000000}, /*n:*/{0.577349, 0.577349, -0.577349} },
    {/*v:*/{1.000000, -1.000000, 1.000000}, /*n:*/{0.577349, -0.577349, -0.577349} },
    {/*v:*/{-1.000000, -1.000000, 1.000000}, /*n:*/{-0.577349, -0.577349, -0.577349} },
    {/*v:*/{1.000000, 1.000000, -1.000000}, /*n:*/{0.577349, 0.577349, 0.577349} },
    {/*v:*/{-1.000000, 1.000000, -1.000000}, /*n:*/{-0.577349, 0.577349, 0.577349} },
    {/*v:*/{0.999999, 1.000000, 1.000001}, /*n:*/{0.577349, -0.577349, 0.577349} },
    {/*v:*/{1.000000, -1.000000, -1.000000}, /*n:*/{0.577349, 0.577349, -0.577349} },
    {/*v:*/{1.000000, 1.000000, -1.000000}, /*n:*/{0.577349, 0.577349, 0.577349} },
    {/*v:*/{1.000000, -1.000000, 1.000000}, /*n:*/{0.577349, -0.577349, -0.577349} },
    {/*v:*/{1.000000, -1.000000, 1.000000}, /*n:*/{0.577349, -0.577349, -0.577349} },
    {/*v:*/{0.999999, 1.000000, 1.000001}, /*n:*/{0.577349, -0.577349, 0.577349} },
    {/*v:*/{-1.000000, -1.000000, 1.000000}, /*n:*/{-0.577349, -0.577349, -0.577349} },
    {/*v:*/{-1.000000, -1.000000, 1.000000}, /*n:*/{-0.577349, -0.577349, -0.577349} },
    {/*v:*/{-1.000000, 1.000000, 1.000000}, /*n:*/{-0.577349, -0.577349, 0.577349} },
    {/*v:*/{-1.000000, 1.000000, -1.000000}, /*n:*/{-0.577349, 0.577349, 0.577349} },
    {/*v:*/{1.000000, 1.000000, -1.000000}, /*n:*/{0.577349, 0.577349, 0.577349} },
    {/*v:*/{1.000000, -1.000000, -1.000000}, /*n:*/{0.577349, 0.577349, -0.577349} },
    {/*v:*/{-1.000000, -1.000000, -1.000000}, /*n:*/{-0.577349, 0.577349, -0.577349} },
    {/*v:*/{-1.000000, -1.000000, -1.000000}, /*n:*/{-0.577349, 0.577349, -0.577349} },
    {/*v:*/{1.000000, -1.000000, -1.000000}, /*n:*/{0.577349, 0.577349, -0.577349} },
    {/*v:*/{-1.000000, -1.000000, 1.000000}, /*n:*/{-0.577349, -0.577349, -0.577349} },
    {/*v:*/{-1.000000, 1.000000, -1.000000}, /*n:*/{-0.577349, 0.577349, 0.577349} },
    {/*v:*/{-1.000000, 1.000000, 1.000000}, /*n:*/{-0.577349, -0.577349, 0.577349} },
    {/*v:*/{0.999999, 1.000000, 1.000001}, /*n:*/{0.577349, -0.577349, 0.577349} },
    {/*v:*/{1.000000, 1.000000, -1.000000}, /*n:*/{0.577349, 0.577349, 0.577349} },
    {/*v:*/{0.999999, 1.000000, 1.000001}, /*n:*/{0.577349, -0.577349, 0.577349} },
    {/*v:*/{1.000000, -1.000000, 1.000000}, /*n:*/{0.577349, -0.577349, -0.577349} },
    {/*v:*/{0.999999, 1.000000, 1.000001}, /*n:*/{0.577349, -0.577349, 0.577349} },
    {/*v:*/{-1.000000, 1.000000, 1.000000}, /*n:*/{-0.577349, -0.577349, 0.577349} },
    {/*v:*/{-1.000000, -1.000000, 1.000000}, /*n:*/{-0.577349, -0.577349, -0.577349} },
    {/*v:*/{-1.000000, -1.000000, -1.000000}, /*n:*/{-0.577349, 0.577349, -0.577349} },
    {/*v:*/{-1.000000, -1.000000, 1.000000}, /*n:*/{-0.577349, -0.577349, -0.577349} },
    {/*v:*/{-1.000000, 1.000000, -1.000000}, /*n:*/{-0.577349, 0.577349, 0.577349} },
    {/*v:*/{-1.000000, 1.000000, -1.000000}, /*n:*/{-0.577349, 0.577349, 0.577349} },
    {/*v:*/{1.000000, 1.000000, -1.000000}, /*n:*/{0.577349, 0.577349, 0.577349} },
    {/*v:*/{-1.000000, -1.000000, -1.000000}, /*n:*/{-0.577349, 0.577349, -0.577349} },
};

// Example OpenGL ES 1.1 Drawing Code:
// glEnableClientState(GL_VERTEX_ARRAY);
// glEnableClientState(GL_NORMAL_ARRAY);
// glVertexPointer(3, GL_FLOAT, sizeof(VertexData3D), &MeshVertexData[0].vertex);
// glNormalPointer(GL_FLOAT, sizeof(VertexData3D), &MeshVertexData[0].normal);
// glDrawArrays(GL_TRIANGLES, 0, kMeshNumberOfVertices);
// glDisableClientState(GL_VERTEX_ARRAY);
// glDisableClientState(GL_NORMAL_ARRAY);
4
  • That exported file looks a bit wrong to me. It only contains 35 or so vertices, and they all have either -1.0 or 1.0 or 0.0 for their values. That's ... weird. Are you sure you're using the right export script version? Also, did you use his sample project and tried to replace your file with it? Sep 12, 2012 at 22:17
  • @VladimirMitrovic: i din't get any sample apps yet. If you have , please share the link/info about it. Sep 13, 2012 at 6:37
  • In this blog from 2009 the author of that exporter posted a link to an archive containing the stuff you need. However, the link seems to be dead. You should contact him (he's been quite active recently) and maybe he can give you what you want. But if you are familiar with OpenGL (you can draw stuff on the screen, set normals, texture it, etc), you are better off writing the exporter and the format yourself. Or I can do that for you (I love writing exporters for Blender :)) Sep 15, 2012 at 12:16
  • @VladimirMitrovic: thanks for you help. I have used the NinevehGL instead of Blender. NinevehGL is a 3D engine forged with pure Obj-C. nineveh.gl Sep 17, 2012 at 9:56

1 Answer 1

0

I have used the NinevehGL instead of Blender.

NinevehGL is a 3D engine forged with pure Obj-C

NinevehGL is now on BETA 0.9.3 version

You can check the details about NinevehGL here

You can see the NinevehGL forum here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.