Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep name of material even if using default material #268

Open
mberglundmx opened this issue Mar 20, 2020 · 1 comment
Open

Keep name of material even if using default material #268

mberglundmx opened this issue Mar 20, 2020 · 1 comment

Comments

@mberglundmx
Copy link

When the .mtl file is missing, the loader Warns and uses a default material. That is all good - however, it would be nice if the default material got the name that is specified in the usemtl line in the obj-file.

In my application I load obj files, and assign them materials based on a completely different physical representation, meaning the .mtl file does not make much sense. But I would still want to be able to read the material names, and map them to my specialized materials.

Currently I achieve this by creating dummy .mtl files, but it would be nice to not have to do that.

If there is an easier way already, please point me in the right direction, thanks!

@syoyo
Copy link
Collaborator

syoyo commented Apr 21, 2020

But I would still want to be able to read the material names, and map them to my specialized materials.

Current usemtl implementation try to map material name to material id, and name -> id mapping should be known in advance(through mtllib).

You may use callback API to assign custom material id based on material name in .obj

if (callback.usemtl_cb) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants