Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have been modelling some objects inside blender, like a light bulb. I finished the light bulb, and I got a question at the time of export it.

I want to export the light bulb in the wavefront format (.obj), but the light bulb is formed by different meshes, I mean, It's not joined in one mesh. If I export the obj that will be as different meshes inside the .obj

My final question is, for import it in the OpenGL C++ side, it's better to join all the meshes (vertexes) inside one or leave them as separated objects? There will not be any trouble on translating... resizing... etc, if they are not joined?

share|improve this question
1  
I'm pretty sure that you as long as all the meshes which consist of the light bulb will be exported as long as they are the same object (i.e. you can't select the parts individually) I couldn't tell you whether it is more efficient to render all the meshes as the same vertex array(?) in opengl. However I do know that as long as the model space coordinates of the vertices are correct a transformation of all of those vertices should work as expected... –  Luke San Antonio Mar 6 '13 at 0:12
    
So, at that case, the wavefronts does not divide the meshes as blender do? When all the meshes are exported, at the end they are exported as one mesh? –  Spamdark Mar 6 '13 at 0:15
    
basically, if I understand what you are describing, it works because of the wavefront format, each mesh file basically declares all the vertices: v 1.0 1.0 5.0 v 5.0 1.0 4.0 notice each vertex is independent of it's face, which are declared later. In fact now that I think of it, OpenGL has no concept of a mesh, everything is triangles, they are not explicitly connected to each other, therefore another mesh which isn't connected will be no problem, is this making sense? or do I not understand the question. –  Luke San Antonio Mar 6 '13 at 15:09
    
Yeah, that's the question. Can you post it in an answer.... Please? –  Spamdark Mar 6 '13 at 22:12
add comment

1 Answer

up vote 5 down vote accepted

Definitions:

  • Mesh: Any amount of triangles which are positioned to appear as one object.

For example, a cube, it looks like one object and contains 12 triangles. I would call this a mesh.

I'd like to note that this definition is not at all correct, but I will be using it, so it's best to know what I mean.

  • Blender Object: An object in blender which, in object mode, can only be selected as a whole.

For example:

Highlighted blender object

Notice how there is only one object which I can only select as a whole. This is a blender object.

When you export as a .obj file, it exports the whole blender object, including all meshes.

The .obj format:

A .obj file has simple statements. In their simplest form (vertices and faces, no normals) they look like this:

v 1.0 5.0 1.0
v -1.0 2.4673 -12.06

or

f 1 5 3
f 5 1 5

The v stands for vertex it describes a vertex.

The f stands for face it describes a triangle, the example:

f 1 5 3

Means: That there is triangle made of vertex 1, vertex 5, and vertex 3

The order is the same order they are declared in the file

v 1.0 -1.0 -1.0  # 1st vertex
v 1.0 -1.0 1.0   # 2nd vertex
v -1.0 -1.0 1.0  # 3rd vertex
v -1.0 -1.0 -1.0 # hmm...

The important thing to realize is that the concept of a 'mesh' as I call it, does not exist in OpenGL, nor does it exist in the .obj file. It is a special concept and above that, it is Blender's doing.

Therefore, loading this data into a proper parser should come out with the right result, merely because OpenGL doesn't require each vertex array to be only one mesh, because to do so, would be an incredible speed reduction and a crap time for the developer.

Therefore, a blender object, as defined before, can be exported to a .obj file. Once this said file is loaded into your program and read, if properly done, should produce exactly what you expect. Multiple meshes that is.

Hopes this helps, if not I'll try to explain further.

share|improve this answer
    
That's what I call An Answer :D Thank You! That absolutely helped! –  Spamdark Mar 7 '13 at 20:20
    
Thanks, glad I could help –  Luke San Antonio Mar 7 '13 at 21:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.