what is the best format for 3D models for opengl?

Started by
6 comments, last by abolfoooud2 18 years, 11 months ago
regards, i am trying to load some 3D models into a simple opengl example using vertices and faces. i used 3DS Max to create my object and generate the .wrl format file. however this format includes the transformation and rotation values of each component of your object, in case it is compund of many objects. that is not practical. what is the format that can give me only vertices and faces, if anything is available?? i hope someone can pick me up of th gap am stuck in :(
Advertisement
Wavefront OBJ

It's very easy to use and parse, and contains only vertex and face data as long as your models don't contain fancier stuff (like splines/spline-patches/etc).
Thnax for the reply.
i tried Obj and it seems promising, except for one thing:
what does a code like the following mean when it comes to defining the faces?

g Box01
s 1
f 1/1/1 2/2/1 3/3/1
f 2/2/1 4/4/1 3/3/1
s 2
f 3/1/2 4/2/2 5/3/2
f 4/2/2 6/4/2 5/3/2
s 1
...

what does the / have to do with the thingy?
i would say OBJ's are good except materials are stored in a seperate file, which tends to complicate things. That and materials are specified as a directive instead of an implicit part of a group or face. If you are just using geometry, these work as good as any, but if you want to store your texture maps or matrials with your model I always used Milshapes 3d ASCII format. I think 3D studio has a simular one.
Also, i've had problems with performance with my OBJ loader and high poly count models. Can any one help both of us out and cough up a link to a good OBJ loader that supports materials (more than one) and loads quickly with high poly counts?
As your leader, I encourage you from time to time, and always in a respectful manner, to question my logic. If you're unconvinced that a particular plan of action I've decided is the wisest, tell me so, but allow me to convince you and I promise you right here and now, no subject will ever be taboo. Except, of course, the subject that was just under discussion. The price you pay for bringing up either my Chinese or American heritage as a negative is - I collect your f***ing head.
group: Box01

s: i forget

f: <index of vertex>/<index of vertex>/<index of vertex> X3

your vertex indexes are dependent on the order which they are stored in the file. so

1/2/3 ==

v 1.000 0.00 0.00
v 2.000 0.00 0.00
v 3.000 0.00 0.00

As your leader, I encourage you from time to time, and always in a respectful manner, to question my logic. If you're unconvinced that a particular plan of action I've decided is the wisest, tell me so, but allow me to convince you and I promise you right here and now, no subject will ever be taboo. Except, of course, the subject that was just under discussion. The price you pay for bringing up either my Chinese or American heritage as a negative is - I collect your f***ing head.
tanx anist for your clarifications
unfortunately, Milkshape 3D ASCII replicates the data in the exported file. for instance, if u design a simple cube with 8 vertices, u end up having 20 vertices in the Milkshape 3D ASCII exported file. thats is goinna be too much waste if you have complecated objects.
Obj is good for now. but i thnk i will face problems later when i want to map textures on it.
lets hope somebody will help us :)

Fadi
Actually, splitting the vertices is necessary when they don't share the same normal or U/V information. It's as efficient as it can be. If you store separate arrays and separate indices, it'll actually take MORE space for any mesh of real complexity, than storing the single pre-split vertex array. Not to mention that's the way the hardware wants it. Also: the cube is pretty much the worst example, because each vertex splits into three. Most normal, more complex, meshes only get a split ratio of 10-30%.

For more information on vertex array splitting, see here.

Regarding file formats: why not take the .wrl file and post-process it to transform the vertices to whatever format you want? Or maybe use the IGameExporter interface (part of the SDK that comes with Max) and write your own? Or write an XML exporter using MaxScript -- Ogre3D has one you can look at if you want. Or perhaps take something pre-made, such as Cx.
enum Bool { True, False, FileNotFound };
hplus0603,

thank u for ur help.
concerning the wrl format, i tried it but it did not work as i wanted. i desinged a simple object that is compound of 4 distinct shapes (boxes with lots of vertices). when i try to draw it, i get defaced final result. the problem that i noticed is that the wrl format defines translation and rotation values for each single shape in ur design. this means that all of the objects are centered and drawn in the same position, then transformed. thats why i couldnt make any use of it.

and concerning the IGameExporter interface , i found it and downloaded it, but didnt know how to use it!!! it is all header and dll files.

This topic is closed to new replies.

Advertisement