Log in or register to post comments

header file generated from obj2opengl fail to compile

November 28, 2012 - 8:30pm #1

I've used the obj2opengl script to convert some model and I got compilation error when I used it in the project.

it turns out that the texCoord array contains some blank value and cannot be compiled . I tried to delete those blank value but then the program won't work. how do I solve this problem?

 

here's some of the blank value on the .h file 

 

 

float dog_02TexCoords [] = {

  // f 3/1431/3 197/1/197 4/2/4

  0.235946, 0.395279,

  0.212643, 0.327336,

  0.217045, 0.388558,

  // f 197/1430/197 3/3/3 1/4/1

  0.212643, 0.327336,

  0.235946, 0.395279,

  0.262182, 0.301458,

  // f 199/5/199 1/6/1 18/7/18

  0.336774, 0.296922,

  0.262182, 0.301458,

  0.322877, 0.372427,

  // f 3/8/3 18/9/18 1/10/1

  0.235946, 0.395279,

  0.322877, 0.372427,

  0.262182, 0.301458,

  // f 2/11/2 7/12/7 6/13/6

  0.417335, 0.193511,

  0.448565, 0.226249,

  0.483148, 0.171084,

 // f 786//786 785//785 775//775 776//776

  , ,

  , ,

  , ,

  // f 787//787 786//786 776//776 777//777

  , ,

  , ,

  , ,

  // f 787//787 786//786 776//776 777//777

  , ,

  , ,

  , ,

  // f 788//788 787//787 777//777 778//778

  , ,

  , ,

  , ,

  // f 788//788 787//787 777//777 778//778

  , ,

  , ,

  , ,

  // f 789//789 788//788 778//778 779//779

  , ,

  , ,

  , ,

  // f 789//789 788//788 778//778 779//779

  , ,

  , ,

  , ,

  // f 790//790 789//789 779//779 780//780

  , ,

  , ,

  , ,

  // f 790//790 789//789 779//779 780//780

  , ,

  , ,

  , ,

  // f 791//791 790//790 780//780 781//781

  , ,

  , ,

  , ,

  // f 791//791 790//790 780//780 781//781

  , ,

  , ,

  , ,

  // f 792//792 791//791 781//781 782//782

  , ,

  , ,

  , ,

  // f 792//792 791//791 781//781 782//782

  , ,

  , ,

  , ,

  // f 783//783 792//792 782//782 773//773

  , ,

  , ,

  , ,

 

 

header file generated from obj2opengl fail to compile

December 12, 2012 - 5:45am #9

I see.

Thanks for the Blender export tip; very helpful to share this here !

 

header file generated from obj2opengl fail to compile

December 12, 2012 - 5:06am #8

hehe I am afraid that's not a feasible option.
I'm still new in this 3D development and  don't really understand about it. plus I don't know how to exporting models per part. LOL

maybe I'll look after different model though. 

 

ah by the way I am able to get the correct header file by reexporting the obj file with blender and then convert it with obj2opengl ..

just remember to export the normal and triangular face.

 

thank you very much this forum is really great :)

header file generated from obj2opengl fail to compile

December 10, 2012 - 2:46am #7

Hi, 

if you have models made up of multiple parts, where each part has a different material/texture, then the easiest would be to export the individual parts of the complex model, creating more than one exported file;

for example, if you have an airplane with fuselage (one texture) and wings (a different texture), the easiest would be to export the fuselage and the wings separately, and then load the various blocks in the Vuforia App.

Otherwise you would need to write an OBJ parser that identifies the different sub-parts and their associated materials, but that would be definitively more complex (lots of code to write).

I hope this helps.

 

header file generated from obj2opengl fail to compile

December 9, 2012 - 3:21pm #6

hi AlessandroB ,

 

the link you give brings to 404 pages. but luckily after I googled I got the right link http://ksolek.fm.interia.pl/Blender/

thanks for the idea. I'll give it a try.

 

and one more things here. I got some models that use more than one texture file . how do I load and apply those texture in the  program?

header file generated from obj2opengl fail to compile

December 3, 2012 - 1:59am #5

Hi fugogugo, 

I hope you can sort it out; in my experience, creating simple meshes in Blender and then exporting to OBJ usually does not create such problems like the one you experience; however I never tried with more complex models.

However, I investigated another option, which could be interesting; read here below:

There exist a few plugins (addons) to export a 3D model from Blender directly to a C++ header file which is suitable for OpenGL rendering; one such add-on can be found at the following address:

http://ksolek.fm.interia.pl/Blender/ 

Note that the add-on above is given as an example, but other add-ons with similar or equivalent functionalities might exist as well on the web. 

The output is once again a header file containing some vertex array definitions (like in the case of the obj2opengl Perl script mentioned previously); however the advantage of the Blender add-on approach is that the user will NOT need to pass through the OBJ format as an intermediate step, but he will be able to export any 3D scene to OpenGL directly from the Blender editing environment.

Rendering

The output produced by the Blender exporter will contain a vertex structure definition with one or more attributes and a vertex array definition based on such structure, like in the following example:

//#define VERTEX_COUNT 24

//#define FACES_COUNT 12

//#ifndef VERTEX_STRUCT

//#define VERTEX_STRUCT

struct vertex_struct {

                float x, y, z;

                float nx, ny, nz;

                float u, v;

                };               

#endif

struct vertex_struct vertexs[] ={

                {1.000000, 1.000000, -1.000000, 0.000000, 0.000000, -1.000000, 0.0, 0.0},

                {1.000000, -1.000000, -1.000000, 0.000000, 0.000000, -1.000000, 0.0, 0.0},

                //…

};

//#define INX_TYPE GL_UNSIGNED_SHORT

unsigned short indexes[] = {0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7,

                8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15,

                16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23};

 In the definition above, the various vertex attributes are packed together (interleaved) in the vertex array; the following code snippet shows how to render such an interleaved array with OpenGL: 

const int STRIDE = 8*sizeof(float);//byte offset between attribs:3(pos)+3(norm)+2(texcoord)=8 

glEnableVertexAttribArray(vertexHandle);

glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, STRIDE, (const GLvoid*) &vertexs[0]);

//setup the normal array

const int normalOffset = 3;

glEnableVertexAttribArray(normalHandle);

glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, STRIDE, (const GLvoid*) &vertexes[normalOffset]);

 

 

header file generated from obj2opengl fail to compile

November 30, 2012 - 2:49pm #4

Okay thank you for the help.

I have gone through opening the OBJ with blender and re-export it.

but no luck. the texture is missing. well maybe I'll take a look at it again 

 

thanks :) 

header file generated from obj2opengl fail to compile

November 30, 2012 - 3:57am #3

Hi, I looked at your file and tried to convert, and indeed the generated file is missing coordinates;

it could be a bug in the conversion script, maybe try exporting the OBJ again from Blender or test with different models;

for the rest, not much I can do about this, unfortunately.

 

header file generated from obj2opengl fail to compile

November 29, 2012 - 2:00am #2

Hi, can you PM me your OBJ mesh file ? I can take a look at it.

 

Log in or register to post comments