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

Cannot find the path to access texture field in MMD material #364

Open
ArpegorPSGH opened this issue Aug 30, 2021 · 1 comment
Open

Cannot find the path to access texture field in MMD material #364

ArpegorPSGH opened this issue Aug 30, 2021 · 1 comment

Comments

@ArpegorPSGH
Copy link

Hello,
I am trying to write a script to automatically create MMD materials inside Blender as copy of existing ones, but with the addition of a texture. However, I can't find a way to access the texture field of the MMD material to give it a value. How could I manage that?

Thank you in advance,
ArpegorPSGH

@powroupi
Copy link
Owner

powroupi commented Sep 8, 2021

Here is the pseudo code:

from mmd_tools.core.material import FnMaterial

source = FnMaterial(source_material)
target = FnMaterial(target_material)

source_base_tex = source.get_texture()
if source_base_tex:
    target.create_texture(source_base_tex.image.filepath)

source_sphere_tex = source.get_sphere_texture()
if source_sphere_tex:
    target.create_sphere_texture(source_sphere_tex.image.filepath)
target_material.mmd_material.sphere_texture_type = source_material.mmd_material.sphere_texture_type

target_material.mmd_material.is_shared_toon_texture = source_material.mmd_material.is_shared_toon_texture
target_material.mmd_material.shared_toon_texture = source_material.mmd_material.shared_toon_texture
target_material.mmd_material.toon_texture = source_material.mmd_material.toon_texture

#Another way
copy_material = source_material.copy()

FnMaterial(copy_material).create_texture(filepath_of_base_texture)

FnMaterial(copy_material)..create_sphere_texture(filepath_of_sphere_texture)
copy_material.mmd_material.sphere_texture_type = "0", "1", "2", or "3"

copy_material.mmd_material.is_shared_toon_texture = True or False
copy_material.mmd_material.shared_toon_texture = 0 ~ 9
copy_material.mmd_material.toon_texture = filepath_of_custom_toon_texture

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

No branches or pull requests

2 participants