Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

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

4: Adsense

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   

258
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
 






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.