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

Also add map_Kd to the OBJ/MTL material kwargs #2332

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ChuangTseu
Copy link

While all the other key/values for the MTL material are provided directly on top of Trimesh's interpretation for SimpleMaterial, then accessible through material.kwargs which is useful for custom handling of the materials, map_Kd isn't. I've had a need for getting the map_Kd file path directly instead of the already loaded PIL.Image.

While all the other key/values for the MTL material are provided directly on top of Trimesh's interpretation for SimpleMaterial, then accessible through material.kwargs which is useful for custom handling of the materials, map_Kd isn't.
I've had a need for getting the map_Kd file path directly instead of the already loaded PIL.Image.
@mikedh
Copy link
Owner

mikedh commented Jan 2, 2025

Thanks for the PR! I guess this would be accessed through: mesh.visual.material.kwargs['file_name']? That seems like it could be a little ambiguous, what if just added it on as a runtime patch value which isn't the greatest but is probably a little clearer:

img = Image.open(util.wrap_as_stream(file_data))
# add the file name on as a runtime attribute
img.file_name = file_name
material["image"] = img

I was also thinking about making a class LazyImage(PIL.Image) which didn't actually load the image until it was accessed, maybe at some point in the future.

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

Successfully merging this pull request may close these issues.

2 participants