Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 18 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


Multi-Mesh Models from .obj and .mtl - C++ Model Factory


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 mynameisnafe   Members   -  Reputation: 256

Like
0Likes
Like

Posted 23 February 2014 - 11:50 AM

Hi all,

 

I'm looking for some advice regarding .obj and .mtl files.

 

I have .obj and .mtl file loaders - they load a .obj model as one mesh and a vector of materials from the .mtl.
Each mesh can be assigned a material.
 

I'd like to split up the faces that I pull in from the .obj loader into meshes, so each mesh can be used with the material in the .mtl file that it's assigned to, i.e., so I can use the material data as GL Uniform Data (colours, tex ids).

This way I can build build up a Model of Meshes, with each mesh having it's own material. I can add Model to a scenegraph and it can Render its Meshes. So far so so.

Mesh
{
  Vec3 *v, *n, *c, *uv, *indices; Material *material;
};

GLMesh
{
  VAO*, Shader*, Mesh*
};

The question is, how best to do this for .obj files?

I'd do it in the loader, of course, and assign the right material to the right mesh.

But how do you decide what is a mesh (when a mesh starts and ends) in .obj?
1) Each 'usemtl ', find a mesh with that material name or create a mesh, and add to those vertices, indices, etc, find the material in the vector of Materials later and copy it to the Mesh ?

 

2) Each 'g ', start a new mesh, and use the last 'usemtl ' as that meshes material name, find the material in the vector of Materials  later and copy it over to the Mesh?

Any .obj vets?

Thanks in advance
 



Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS