Jump to content

Using Blender models in OpenGL: Which format?

- - - - -

  • Please log in to reply
2 replies to this topic

#1
artificial

artificial

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 624 posts
Hi!

I have a problem that might seem noobish to you. Unfortunately, I couldn't solve it myself, so I'm in need of your help.

I'm programming a 3D game at the moment and I'm tired of creating models manually by typing in the vector-coordinates.
Instead, I'd like to create the models in Blender for they can be more complex.
Now I don't know which given format I should use. I actually just need the vector-coordinates (arranged like triangles), the normal-vectors and the texture-coordinates.

So, which format would you suggest?

I tried some, but still I wonder about a few things.
For example, this is Blender's standard cube exported as a Wavefront-file (.obj):
# Blender3D v246 OBJ File: 

# www.blender3d.org

mtllib Cube.mtl

o Cube

v 1.000000 -1.000000 -1.000000

v 1.000000 -1.000000 1.000000

v -1.000000 -1.000000 1.000000

v -1.000000 -1.000000 -1.000000

v 1.000000 1.000000 -1.000000

v 0.999999 1.000000 1.000001

v -1.000000 1.000000 1.000000

v -1.000000 1.000000 -1.000000

vn 0.000000 0.000000 -1.000000

vn -1.000000 -0.000000 -0.000000

vn -0.000000 -0.000000 1.000000

vn -0.000001 0.000000 1.000000

vn 1.000000 -0.000000 0.000000

vn 1.000000 0.000000 0.000001

vn 0.000000 1.000000 -0.000000

vn -0.000000 -1.000000 0.000000

usemtl Material

s off

f 5//1 1//1 8//1

f 1//1 4//1 8//1

f 3//2 7//2 8//2

f 3//2 8//2 4//2

f 2//3 6//3 3//3

f 6//4 7//4 3//4

f 1//5 5//5 2//5

f 5//6 6//6 2//6

f 5//7 8//7 7//7

f 5//7 7//7 6//7

f 1//8 2//8 3//8

f 1//8 3//8 4//8

Why are there eight instead of twelve vertices? Is the last part supposed to tell the engine how to draw the model?

Greets,
artificial
Sometimes words ain't enough to express something. That's why computer scientists use double words.

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
I am not a Blender guru but I had found the .obj specification that will most likely be of interest to you:
http://www.martinred...gfx/3d/OBJ.spec

As for the selection of formats, unless working with Direct X then OBJ files seem the best way to go. Depends if your game engine supports it.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
artificial

artificial

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 624 posts
@Nullw0rm: Thanks for that link. :)

If anyone else has a possible solution, feel free to post it.

EDIT: Is there any model format that you can recommend for my undertaking?

EDIT2: The PLY file format looks decent.

Edited by artificial, 16 October 2010 - 10:11 AM.
EDIT2

Sometimes words ain't enough to express something. That's why computer scientists use double words.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users