Log in or register to post comments

obj 2 opengl

March 19, 2012 - 9:59am #1

Hello,
I am starting to use Vuforia, and I would like to use my own 3D Model instead of the TeaPot, so I have tried the script "obj2opengl.pl" to transform my .obj into a .h file.

But it turns that the final ".h file" has only a Verts and TexCoords, but no Normal or Indices like the Teapot or the Banana example. So when I play it, it doesn't show any texture.

Is there other way to transform .obj 3D models into .h file?
Is there other way to produce a 3D model into a .h file?

I am sorry, I know this is a very repeated topic but I don't find any final solution to this problem.

Thank you so much

Re: obj 2 opengl

March 30, 2012 - 2:52am #12

I was having issue with this part it turns out:
The suggestion from http://ar.qualcomm.at/node/2001813

For me it needed to be set = to 0 rather than ""
[CODE" />unsigned int CubeAnimationTexturedNumVerts = 0;[/CODE" />

Re: obj 2 opengl

March 30, 2012 - 1:32am #11

I think I'm having issues related to this.
Trying to export from blender.
The application runs. And I get the shape but its very jaggy and broken looking.
Is it ok for me to use the teapot texture on another model?
I dont have high quality normals as an option on my version of blender

Re: obj 2 opengl

March 29, 2012 - 4:01pm #10

Perhaps you're overrunning your arrays (causing an array out of bounds exception)? For instance numVerts in the snippet above is the number of vertices, not the size of the vertex array.

- Kim

Re: obj 2 opengl

March 29, 2012 - 4:39am #9
ksiva wrote:

Use glDrawArrays instead of glDrawElements:

glDrawArrays(GL_TRIANGLES, 0, numVerts);

In that case you don't need indices.

- Kim

Thank you Mr.ksiva

i'm do that and the project has been built successfully ...
but when i run the project and detect the target marker it's freez the camera and exit from application and write this error in Xcode:

error: failed to launch '/Users/khaled/Library/Developer/Xcode/DerivedData/ImageTarget-cpiwdvmeppdxbpsiqrmbqnuape/Build/Products/Debug-iphoneos/ImageTargets.app/ImageTargets' -- device locked

What's the problem?

Re: obj 2 opengl

March 28, 2012 - 7:43pm #8

Use glDrawArrays instead of glDrawElements:

glDrawArrays(GL_TRIANGLES, 0, numVerts);

In that case you don't need indices.

- Kim

Re: obj 2 opengl

March 28, 2012 - 2:24am #7

I already used obj2opengl script but it don't solve my problem because it doesn't generate all arrays (numVertices, vertices, normals, texCoords, numIndices, indices) like "teapot.h" example

please tell me how i display the banana object used this .h file?

Re: obj 2 opengl

March 28, 2012 - 2:06am #6

Hi,
as I know it isn't possible to export directly to a .h file. First you have to export your Object into a .obj file (Only static Objects can be stored in an .obj file). After that, follow the explanation on this site "http://heikobehrens.net/2009/08/27/obj2opengl/" or search for obj2opengl in this forum.

Re: obj 2 opengl

March 28, 2012 - 1:56am #5
Sceada wrote:

Hi,
nice to hear that the transformation works.
I use Blender too!

How can you generate .h file by blender?!!!

Re: obj 2 opengl

March 20, 2012 - 6:25am #4

Hi,
nice to hear that the transformation works.
I use Blender too!

Re: obj 2 opengl

March 20, 2012 - 4:45am #3

Hello Sceada,
thank you so much. Everything works more or less as expected :)

These are the options that I could check

Are you producing your 3D Models in Blender and then using the obj2opengl Pearl script? Or are you using a different way?

Re: obj 2 opengl

March 19, 2012 - 10:28am #2

Which program do you use to export your .obj model?

If you use Blender for the export, do the following checks:

  • Edges
  • Normals
  • High Quality Normals
  • UVs
  • Materials
  • Triangulate
  • Apply Modifiers

For your indices use this value inside of your object .h file
"unsigned int CubeAnimationTexturedNumVerts = "";"

Log in or register to post comments