Wings3D .obj file -> OpenGL problem - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Wings3D .obj file -> OpenGL problem (/thread-4626.html)
Pages: 1 2
Wings3D .obj file -> OpenGL problem - WhatMeWorry - Jan 8, 2006 11:47 PM
I went into wings3D and created a simple cube. I then
exported it to a .obj file. This is what was created:
The .obj is then read into my OpenGL file for a wire frame object.
Not sure what I'm doing, but I looked at a StanfordBunny example for
a starting place with the following code:
At least I get something, but It's not a cube; more like two
upright parallel squares with a connecting X at their bottom face.
I also try and create a solid object from the same data. With
Instead of solidcube, I get sort of two bent solid triangles kinda arranged
about a cube.
Anybody see my mistake(s)?
Wings3D .obj file -> OpenGL problem - akb825 - Jan 9, 2006 12:05 AM
I don't think you understand the concept of obj files very well. You have the vertex list, then you have the faces. The faces are what you use to create the actual shape. What you will need to do is read in all the vertices, vertex texture coordinates, and vertex normals. Once you do that, you will need to read in the indices that the faces give you (those indices start at 1 for some odd reason), and resolve those into the correct vertices, vertex texture coordinates, and normals. This is no small task, mainly because they are stupid and don't provide the item counts for obj files. () I just completed the obj loader for a program I'm making that will assist me in putting models into games. (the final format will be a binary format of my making, though, which will be much faster in loading as well as smaller) The function to load the obj files is 900 lines long, and I have 2 specially created linked lists, one to find the counts that I need for the indices for the vertex arrays, and one to assist in resolving which index points to which vertex. (and also removes copies of vertices) This also includes material file importing, though.
Wings3D .obj file -> OpenGL problem - Leisure Suit Lurie - Jan 9, 2006 06:02 AM
Some apps do put those counts in a comment block.
Wings3D .obj file -> OpenGL problem - Cochrane - Jan 9, 2006 09:28 AM
The first code should have glVertex3d instead of glVertex2d.
Wings3D .obj file -> OpenGL problem - LongJumper - Jan 9, 2006 11:11 AM
Now, for some actual help:
1. Go here: http://www.sfu.ca/~kberg/Code/sourcecode.html
2. Download the source for the wavefront obj loader.
You won't be able to write your own, and this one works.
Wings3D .obj file -> OpenGL problem - Fenris - Jan 9, 2006 11:14 AM
Also, don't forget that .obj starts indexing at one, not zero.
Wings3D .obj file -> OpenGL problem - ThemsAllTook - Jan 9, 2006 12:06 PM
LongJumper Wrote:You won't be able to write your own, and this one works.
A rudimentary .obj loader is trivial to write. I did it in an evening. If you want a full-featured loader, it would take a little bit more effort, but really not that much.
Wings3D .obj file -> OpenGL problem - WhatMeWorry - Jan 9, 2006 04:19 PM
Quote:A rudimentary .obj loader is trivial to write. I did it in an evening.
Maybe for you, but it would take me a month and even
then not work right
I'll try the loader first. Also study the code; should learn alot.
Wings3D .obj file -> OpenGL problem - LongJumper - Jan 9, 2006 04:55 PM
I was trying to relate to his abilities at this point in time. That "you" was not a universal quantifier
Good luck, that .obj loader was one of the big stepping stones for learning OpenGL for me.
Wings3D .obj file -> OpenGL problem - WhatMeWorry - Jan 10, 2006 12:48 AM
Just for closure:
I Downloaded that .obj loader (just 2 files - ModelType.h and ModelType.cpp),
moved it into my Xcode project, put in a LoadObj() and Draw() method
calls into my code, recompiled, and bam! Perfect openGL 3D drawings.
It doesn't get better that this.
BTW, I did look at the loader and code and yes it has me stymied. I'll study and undersand it eventually, but right now I'm just having too much 3D fun.
If any 3D newbie is reading this, I can't recommend highly enough Wings3D
and the above link to the (.obj loader) ModelType class.
Thanks again all!
Wings3D .obj file -> OpenGL problem - eShad0w - Jun 5, 2006 10:47 AM
WhatMeWorry Wrote:I Downloaded that .obj loader (just 2 files - ModelType.h and ModelType.cpp),
Can you please be more specific with that, what and where exactly should I put in my project in order for it to load (call) my obj file?
Wings3D .obj file -> OpenGL problem - Ingemar - Jun 9, 2006 11:53 PM
LongJumper Wrote:Now, for some actual help:Writing an OBJ loader, at least a basic one that loads straight mesh data is very straight forward. (OBJs hold some more data, like spline representations, but I never touched them.) I have looked at several OBJ samples, but still find it easier to write my own, since I otherwise must rewrite much of someone else's code to adjust the output format and add postprocessing. I have actually done the whole thing twice - with post processing. (I wasn't happy with the first module so I wrote a new one rather than fixing the old one.)
With post processing, I mean breaking down polygons to triangles (so I can use glDrawElements and similar), and calculating texture coordinates and normal vectors, in case they are not provided in the OBJ. That's a lot more work, but still quite managable.
Wings3D .obj file -> OpenGL problem - flash - Jun 24, 2006 02:59 AM
I'm trying to do a similar thing - read a .obj file and display it. I'm using GLUT and C++ atm.
I've been using models with no texture data to start off with and I got to the stage (in an evening) where I could read in all the vertices, normals and face information fine and various models all displayed happily using GL_LINE as the polymode for back and front faces (wireframe).
Now I'm trying to display these models with GL_FILL and basic lighting and I've run into a problem: the vertices for the faces don't seem to be consistently specified in order in the .obj - i.e. some are clockwise, some are anticlockwise. So my display routine draws some faces the right way round, some the wrong way round and the normals are reversed for some and not for others.
I've loaded the same models into Blender and it displays them fine, so presumably there is a way of fixing this.
Is there an obvious way of telling which faces are specified anti-clockwise and which are clockwise so I can reverse them? Is there another kind of solution? Or does it sound like something else is wrong?
Any help would be appreciated...
Wings3D .obj file -> OpenGL problem - unknown - Jun 24, 2006 03:28 AM
flash: are you remembering that the vertices you read in will probably be stored in a 0 index array and the polygons in an obj file reference vertices with a starting index of 1?
Wings3D .obj file -> OpenGL problem - OneSadCookie - Jun 24, 2006 04:03 AM
flash: I've never had a problem with Wings' export, but maybe Blender doesn't do such a good job.
You can tell which way the polygon is wound by looking at the dot product of the vertex normals with the face normal, I think.