General => Feedback => Topic started by: cyberkilla on January 20, 2007, 12:15:50 pm

Title: Wavefront OBJ Format
Post by: cyberkilla on January 20, 2007, 12:15:50 pm
I wonder if anyone has planned a loader for this?
It seems to be the ONLY format Blender exports properly!
I am shocked to find out that:

MD2 Models export as a solid block of disortion, but with correct UV Coords!

3DS Models export as a correct model, but entirely destroyed UV Coords,
and no reference to the texture!

ASC is not supported, not even a plugin can be found.

JAW is naturally not supported.
It is sickening that is doesn't work. I like these OBJ formats more and more.
I would like to build one myself eventually, but I have only minimal free time right now.

If anyone has any ideas about a workaround, I'd appreciate it.
Regardless of any help, I will be making an OBJ loader at some point:)
How on earth could they make a faulty MD2 importer? The format is so simple, there are even tutorials!

I will post any links I can find that are interesting...
That last link has some example import/export source code,
and many small examples of models.
Look how simple it looks...
Code: [Select]

# cube.obj
g cube
v  0.0  0.0  0.0
v  0.0  0.0  1.0
v  0.0  1.0  0.0
v  0.0  1.0  1.0
v  1.0  0.0  0.0
v  1.0  0.0  1.0
v  1.0  1.0  0.0
v  1.0  1.0  1.0

vn  0.0  0.0  1.0
vn  0.0  0.0 -1.0
vn  0.0  1.0  0.0
vn  0.0 -1.0  0.0
vn  1.0  0.0  0.0
vn -1.0  0.0  0.0
f  1//2  7//2  5//2
f  1//2  3//2  7//2
f  1//6  4//6  3//6
f  1//6  2//6  4//6
f  3//3  8//3  7//3
f  3//3  4//3  8//3
f  5//5  7//5  8//5
f  5//5  8//5  6//5
f  1//4  5//4  6//4
f  1//4  6//4  2//4
f  2//1  6//1  8//1
f  2//1  8//1  4//1
Title: Wavefront OBJ Format
Post by: EgonOlsen on January 20, 2007, 01:00:26 pm
Aren't there any free converters from obj to 3ds/md2 that will do the job? Deep Exploration (i think it's now called 3D Exploration or something) can do it, but it's a commercial application. The example you've posted looks simple, but it lacks information about u/v-coodinates, textures etc...
I may have a look on the links if i find the time to see how simple it really is...

Edit: Maybe this can help: http://www.wings3d.com?
Title: Wavefront OBJ Format
Post by: cyberkilla on January 20, 2007, 01:45:28 pm
It seems to be a widely implemented format now.

Yes, wings3d does use it! But it doesnt like Ubuntu Edgy.
I think it is a small library issue. Hopefully I will be able to get it running:).

Because I am running linux, my choice of software is greatly reduced in this area, unfortunately:).

Yes, there is no uv information apparent in that example.
I noticed they also support FreeForm data, but im sure this can be ignored.
I doubt that a lot of people use these features in any format, because it
makes models harder to move between modelers.

One person referred to Blender as a "F***ing Black Hole" - You can put any format into it without significant problems, but NOTHING can escape.

Ive also tried to build a CVS snapshot, which claims to have fixed the 3DS export problems, but the source code is so pathetic, I cant understand any of it. Most importantly neither can the compiler:). Trillions of warnings, and intermittent errors, seemingly caused by hard coded external include paths.

EDIT: For Ubuntu users who need Wings3D.
There is a problem with the version of erlang. This report provides a simple, double click file which fixes with ZERO messing around:)

Link straight to the file download url

Bug report which explains it.
Title: Wavefront OBJ Format
Post by: EgonOlsen on January 20, 2007, 04:18:31 pm
Can you provide an example obj-file that you intend to use? Does obj support keyframes?
Title: Wavefront OBJ Format
Post by: cyberkilla on January 20, 2007, 05:51:52 pm
Yes of course:) I will post it here in a moment, after I verify it is actually working:)

It is my impression that there is no keyframes, but a lot of exporters provide the
ability to automatically export each frame as a separate obj file.

I have found this link which explains a little better...


Basically, it is a format which is unusually common. Even more so than 3ds, because it is described better.

It explains there is a ASCII and a BINARY version. According to the website, the ASCII one is free, and the BINARY one is more propriety, and hidden.

It supports UV Mapping, according to the website, and blender's exporter specs...


It explains that there isn't really any header information needed.
The spec explains that the information is stored on lines, with the first word
describing its purpose...

Code: [Select]

-geometric vertices (v)
-texture vertices (vt)
-vertex normals (vn)

Now the file below, is a model I made. I exported it in blender, and it DOES have "vt" lines, which are texture coords, so it seems to be working.

I have noticed that the exporter offers to save the Material data in a separate file, however, this data can be embedded into the file itself, or, probably, not used at all, because it only points to the filename of the texture, which can be done in jpct anyway.
Title: Wavefront OBJ Format
Post by: cyberkilla on January 20, 2007, 05:52:34 pm
I hope this isnt too messy. If so, I suppose I can use my ftp.

Code: [Select]

EDIT: Removed Model Mesh.
Title: Wavefront OBJ Format
Post by: cyberkilla on January 20, 2007, 06:01:35 pm

If DEFINATELY works in blender!
I tried it in Milkshape, after exporting from Blender, and there is no UV lossage,
and the model itself is intact!

If we could get this working in Jpct, I would be very pleased.
At least 3DS exporting from Milkshape is possible in the meantime.

Egon, If you think its worth adding, I will help in any way possible.

I believe it is one of those formats that will open the engine up a lot more.

3DS is by far the most common format, but there are so many errors in its implementation, it is frightening. It seems to be more about exporting causing issues, rather than the actual importing of the format.

I made an image loader a while back. It was in assembly, and It loaded 24bit Windows Bitmaps. Something like that is easy, because its all explained in the format specs.

This OBJ seems well explained also.
Title: Wavefront OBJ Format
Post by: EgonOlsen on January 21, 2007, 01:51:24 am
Looks quite easy...i'll see what i can do...
Title: Wavefront OBJ Format
Post by: EgonOlsen on January 22, 2007, 11:15:21 pm
Here you go: http://www.jpct.net/download/beta/jpctapi.zip
It loads everything that i tried except for models using polygons with more than 4 points. This would require to add a triangulation algorithm, which i don't want ATM...too much code for such a small gain.
As simple as OBJ looks, it has its quirks. Mainly because there are almost no required fields. An object name can be there, it doesn't have to. The same for group names (i treat objects and groups the same ATM). Each group may contain its own set of vertices, but it may as well use vertices from other groups and so on...i hope that i've found most of these quirks now.
Well, just give it a try and let me know how it goes.
Title: Wavefront OBJ Format
Post by: cyberkilla on January 23, 2007, 12:50:33 am

I will give it a try right away:).
I had no idea you would do it so quickly. Blender has a "Convert Quads to Triangles" function, so that should not be a problem.

Thank you! I do not know what to say;).

It saves me a lot of trouble with additional imports and exports from different
modelers too!

I will report back to you promptly.

Its 12:13am, so I haven't had a chance to test my main models yet,
but I did try a random model which is effectively a triangulated rectangle.

It seems to work without any trouble. Ill test a UV texture in my next attempt.

Well done Egon, I am more than impressed, and in your debt;).
Title: Wavefront OBJ Format
Post by: cyberkilla on January 23, 2007, 10:23:45 am
I have tried my main character, and there is no problem with it!

Well done!
I never use more than 4 points anyway because I find it affects the accuracy of
shading in blender.