Moguri / blend2bam

A CLI tool to convert Blender blend files to Panda3D BAM files
MIT License
68 stars 18 forks source link

Support a way to override the default Settings for an app using autoconversion from Panda3D loader #90

Closed izzyboris closed 7 months ago

izzyboris commented 7 months ago

When using the Panda3D loader to load .blend files, it would be nice to support a way to override the blend2bam.common.Settings properties for an app (e.g., to specify 'copy' textures mode as default, etc.).

This is possible with some monkeypatching, and this would have to be done from any entry point (a main.py as well as a setup.py, etc.), but maybe could be done by making Settings() act like a Singleton that can be configured before calling base.loader.loadModel().

Example of monkeypatching that seems to work:

from dataclasses import dataclass
import blend2bam.common

@dataclass
class Blend2BamSettings(blend2bam.common.Settings):
    textures: str = "copy"

blend2bam.common.Settings = Blend2BamSettings
Moguri commented 7 months ago

You can modify global_settings on BlendLoader:

import blend2bam.loader

blend2bam.loader.BlendLoader.global_settings.textures = 'copy'