"""
布料材质系统
提供布料材质的定义和管理
包含完整的物理和视觉属性定义
"""

from panda3d.core import Vec4, Vec3
from typing import Dict, Any, List, Optional
import math


class ClothMaterial:
    """
    布料材质类
    定义布料的物理和视觉属性，包含完整的材料科学参数
    """
    
    # 预定义的布料材质类型
    TYPE_COTTON = "cotton"
    TYPE_SILK = "silk"
    TYPE_LEATHER = "leather"
    TYPE_RUBBER = "rubber"
    TYPE_DENIM = "denim"
    TYPE_LINEN = "linen"
    TYPE_WOOL = "wool"
    TYPE_SYNTHETIC = "synthetic"
    TYPE_MESH = "mesh"
    TYPE_CANVAS = "canvas"
    TYPE_NYLON = "nylon"
    TYPE_POLYESTER = "polyester"
    TYPE_SATIN = "satin"
    TYPE_TERRY = "terry"
    TYPE_FLEECE = "fleece"
    TYPE_NEOPRENE = "neoprene"
    TYPE_SPANDEX = "spandex"
    TYPE_TWEED = "tweed"
    TYPE_TULLE = "tulle"
    TYPE_VELVET = "velvet"
    TYPE_SUEDE = "suede"
    
    # 材质行为特性
    BEHAVIOR_DEFAULT = "default"
    BEHAVIOR_STIFF = "stiff"
    BEHAVIOR_FLEXIBLE = "flexible"
    BEHAVIOR_ELASTIC = "elastic"
    BEHAVIOR_HEAVY = "heavy"
    BEHAVIOR_LIGHT = "light"
    
    def __init__(self, name: str, material_type: str = TYPE_COTTON, 
                 physical_params: Dict[str, float] = None,
                 visual_params: Dict[str, Any] = None,
                 advanced_params: Dict[str, Any] = None):
        """
        初始化布料材质
        
        Args:
            name: 材质名称
            material_type: 材质类型
            physical_params: 物理参数字典
            visual_params: 视觉参数字典
            advanced_params: 高级参数字典
        """
        self.name = name
        self.material_type = material_type
        self.behavior_mode = self.BEHAVIOR_DEFAULT
        
        # 默认物理参数（基础物理属性）
        self.default_physical_params = {
            'density': 0.6,                    # 密度 (kg/m³)
            'linear_stiffness': 0.7,          # 线性刚度
            'angular_stiffness': 0.6,         # 角度刚度
            'volume_stiffness': 0.4,          # 体积保持刚度
            'friction': 0.6,                  # 摩擦系数
            'restitution': 0.1,               # 恢复系数
            'pressure_coefficient': 0.0,      # 压力系数
            'drag_coefficient': 0.02,         # 阻力系数
            'lift_coefficient': 0.01,         # 升力系数
            'bend_stiffness': 0.5,            # 弯曲刚度
            'damping': 0.01,                  # 阻尼系数
            'plastic_threshold': 0.1,         # 塑性阈值
            'plastic_stiffness': 0.5,         # 塑性刚度
            'tear_threshold': 100.0,          # 撕裂阈值
            'tear_resistance': 50.0,          # 撕裂阻力
            'anisotropic_friction': [0.6, 0.6, 0.6],  # 各向异性摩擦
            'dynamic_friction': 0.6,          # 动态摩擦系数
            'static_friction': 0.7,           # 静态摩擦系数
            'rolling_friction': 0.1,          # 滚动摩擦系数
            'spinning_friction': 0.05,        # 自旋摩擦系数
            'viscosity': 0.01,                # 粘度
            'compressibility': 0.1,           # 可压缩性
            'shear_modulus': 0.7,             # 剪切模量
            'bulk_modulus': 1.2,              # 体积模量
            'youngs_modulus': 1.0,            # 杨氏模量
            'poisson_ratio': 0.4              # 泊松比
        }
        
        # 默认视觉参数
        self.default_visual_params = {
            'color': Vec4(0.8, 0.8, 0.8, 1.0),      # 颜色
            'roughness': 0.7,                       # 粗糙度
            'metallic': 0.0,                        # 金属度
            'specular': 0.2,                        # 镜面反射
            'texture_scale': 1.0,                   # 纹理缩放
            'normal_strength': 1.0,                 # 法线强度
            'emissive': Vec4(0, 0, 0, 0),           # 自发光
            'opacity': 1.0,                         # 不透明度
            'transmission': 0.0,                    # 透射
            'anisotropy': 0.0,                      # 各向异性
            'clearcoat': 0.0,                       # 清漆层
            'clearcoat_roughness': 0.0,             # 清漆粗糙度
            'sheen': 0.0,                           # 光泽
            'sheen_roughness': 0.0,                 # 光泽粗糙度
            'subsurface': 0.0,                      # 次表面散射
            'subsurface_color': Vec4(1, 1, 1, 1),   # 次表面颜色
            'thickness': 1.0                        # 厚度
        }
        
        # 默认高级参数
        self.default_advanced_params = {
            'temperature_sensitivity': 0.0,         # 温度敏感性
            'humidity_sensitivity': 0.0,            # 湿度敏感性
            'aging_factor': 0.0,                    # 老化因子
            'stretch_recovery': 0.8,                # 拉伸恢复
            'compression_recovery': 0.8,            # 压缩恢复
            'fatigue_resistance': 0.9,              # 疲劳抗性
            'abrasion_resistance': 0.8,             # 耐磨性
            'chemical_resistance': 0.7,             # 化学抗性
            'uv_resistance': 0.6,                   # 紫外线抗性
            'flame_resistance': 0.5,                # 阻燃性
            'water_absorption': 0.1,                # 吸水性
            'air_permeability': 0.5,                # 透气性
            'thermal_conductivity': 0.1,            # 热导率
            'electrical_conductivity': 0.0,         # 电导率
            'magnetic_permeability': 1.0,           # 磁导率
            'radiation_absorption': 0.1,            # 辐射吸收
            'biodegradability': 0.3,                # 生物降解性
            'recyclability': 0.8                    # 可回收性
        }
        
        # 合并参数
        self.physical_params = self.default_physical_params.copy()
        if physical_params:
            self.physical_params.update(physical_params)
            
        self.visual_params = self.default_visual_params.copy()
        if visual_params:
            self.visual_params.update(visual_params)
            
        self.advanced_params = self.default_advanced_params.copy()
        if advanced_params:
            self.advanced_params.update(advanced_params)
            
        # 材质状态
        self.temperature = 20.0  # 摄氏度
        self.humidity = 50.0     # 相对湿度百分比
        self.age = 0.0           # 使用年限
        self.wear_level = 0.0    # 磨损程度 (0-1)
        
    def get_physical_parameters(self) -> Dict[str, float]:
        """
        获取物理参数（考虑环境和老化影响）
        
        Returns:
            物理参数字典
        """
        # 应用环境和老化效应
        adjusted_params = self.physical_params.copy()
        
        # 温度影响
        temp_sensitivity = self.advanced_params.get('temperature_sensitivity', 0.0)
        temp_factor = 1.0 + (self.temperature - 20.0) * temp_sensitivity * 0.01
        adjusted_params['linear_stiffness'] *= temp_factor
        adjusted_params['angular_stiffness'] *= temp_factor
        
        # 湿度影响
        humidity_sensitivity = self.advanced_params.get('humidity_sensitivity', 0.0)
        humidity_factor = 1.0 + (self.humidity - 50.0) * humidity_sensitivity * 0.01
        adjusted_params['density'] *= humidity_factor
        
        # 老化影响
        aging_factor = self.advanced_params.get('aging_factor', 0.0)
        aging_multiplier = 1.0 - self.age * aging_factor * 0.01
        adjusted_params['linear_stiffness'] *= aging_multiplier
        adjusted_params['restitution'] *= aging_multiplier
        
        # 磨损影响
        adjusted_params['friction'] *= (1.0 - self.wear_level * 0.2)
        adjusted_params['tear_resistance'] *= (1.0 - self.wear_level * 0.5)
        
        return adjusted_params
        
    def get_visual_parameters(self) -> Dict[str, Any]:
        """
        获取视觉参数（考虑磨损和老化影响）
        
        Returns:
            视觉参数字典
        """
        adjusted_params = self.visual_params.copy()
        
        # 磨损影响颜色和粗糙度
        if self.wear_level > 0:
            # 颜色变暗
            color = adjusted_params['color']
            darkening = 1.0 - self.wear_level * 0.2
            adjusted_params['color'] = Vec4(
                color[0] * darkening,
                color[1] * darkening,
                color[2] * darkening,
                color[3]
            )
            
            # 增加粗糙度
            adjusted_params['roughness'] = min(1.0, 
                adjusted_params['roughness'] + self.wear_level * 0.3)
                
        # 老化影响
        aging_darkening = self.age * 0.05
        if aging_darkening > 0:
            color = adjusted_params['color']
            adjusted_params['color'] = Vec4(
                max(0.0, color[0] - aging_darkening),
                max(0.0, color[1] - aging_darkening),
                max(0.0, color[2] - aging_darkening),
                color[3]
            )
            
        return adjusted_params
        
    def get_advanced_parameters(self) -> Dict[str, Any]:
        """
        获取高级参数
        
        Returns:
            高级参数字典
        """
        return self.advanced_params.copy()
        
    def update_physical_parameter(self, param_name: str, value: float) -> bool:
        """
        更新物理参数
        
        Args:
            param_name: 参数名称
            value: 参数值
            
        Returns:
            是否更新成功
        """
        if param_name in self.physical_params:
            self.physical_params[param_name] = value
            return True
        return False
        
    def update_visual_parameter(self, param_name: str, value) -> bool:
        """
        更新视觉参数
        
        Args:
            param_name: 参数名称
            value: 参数值
            
        Returns:
            是否更新成功
        """
        if param_name in self.visual_params:
            self.visual_params[param_name] = value
            return True
        return False
        
    def update_advanced_parameter(self, param_name: str, value) -> bool:
        """
        更新高级参数
        
        Args:
            param_name: 参数名称
            value: 参数值
            
        Returns:
            是否更新成功
        """
        if param_name in self.advanced_params:
            self.advanced_params[param_name] = value
            return True
        return False
        
    def set_environment_conditions(self, temperature: float = None, 
                                 humidity: float = None):
        """
        设置环境条件
        
        Args:
            temperature: 温度 (摄氏度)
            humidity: 湿度 (相对湿度百分比)
        """
        if temperature is not None:
            self.temperature = temperature
        if humidity is not None:
            self.humidity = max(0.0, min(100.0, humidity))
            
    def simulate_aging(self, years: float):
        """
        模拟材料老化
        
        Args:
            years: 老化年数
        """
        self.age += years
        self.age = max(0.0, self.age)
        
    def simulate_wear(self, wear_amount: float):
        """
        模拟材料磨损
        
        Args:
            wear_amount: 磨损量 (0-1)
        """
        self.wear_level += wear_amount
        self.wear_level = max(0.0, min(1.0, self.wear_level))
        
    def set_behavior_mode(self, behavior_mode: str):
        """
        设置行为模式
        
        Args:
            behavior_mode: 行为模式
        """
        self.behavior_mode = behavior_mode
        
    def get_material_properties_summary(self) -> Dict[str, Any]:
        """
        获取材料属性摘要
        
        Returns:
            属性摘要字典
        """
        return {
            'name': self.name,
            'type': self.material_type,
            'behavior_mode': self.behavior_mode,
            'environment': {
                'temperature': self.temperature,
                'humidity': self.humidity
            },
            'condition': {
                'age': self.age,
                'wear_level': self.wear_level
            },
            'physical_properties': {
                'density': self.physical_params['density'],
                'stiffness': self.physical_params['linear_stiffness'],
                'elasticity': self.physical_params['youngs_modulus'],
                'friction': self.physical_params['friction'],
                'tear_resistance': self.physical_params['tear_resistance']
            },
            'visual_properties': {
                'color': self.visual_params['color'],
                'roughness': self.visual_params['roughness'],
                'metallic': self.visual_params['metallic']
            },
            'advanced_properties': {
                'durability': self.advanced_params['fatigue_resistance'],
                'chemical_resistance': self.advanced_params['chemical_resistance'],
                'uv_resistance': self.advanced_params['uv_resistance']
            }
        }


class ClothMaterialManager:
    """
    布料材质管理器
    管理和提供预定义的布料材质，支持材质混合和自定义
    """
    
    def __init__(self):
        self.materials: Dict[str, ClothMaterial] = {}
        self.material_combinations: Dict[str, Dict[str, Any]] = {}
        self._init_default_materials()
        
    def _init_default_materials(self):
        """
        初始化默认布料材质
        """
        # 棉布 - 天然纤维，透气性好
        cotton = ClothMaterial(
            "Cotton",
            ClothMaterial.TYPE_COTTON,
            {
                'density': 0.6,
                'linear_stiffness': 0.7,
                'angular_stiffness': 0.6,
                'volume_stiffness': 0.4,
                'friction': 0.6,
                'restitution': 0.1,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.02,
                'lift_coefficient': 0.01,
                'bend_stiffness': 0.5,
                'damping': 0.01,
                'plastic_threshold': 0.1,
                'plastic_stiffness': 0.5,
                'tear_threshold': 100.0,
                'tear_resistance': 50.0,
                'anisotropic_friction': [0.6, 0.6, 0.6],
                'dynamic_friction': 0.6,
                'static_friction': 0.7,
                'rolling_friction': 0.1,
                'spinning_friction': 0.05,
                'viscosity': 0.01,
                'compressibility': 0.1,
                'shear_modulus': 0.7,
                'bulk_modulus': 1.2,
                'youngs_modulus': 1.0,
                'poisson_ratio': 0.4
            },
            {
                'color': Vec4(0.9, 0.9, 0.85, 1.0),
                'roughness': 0.8,
                'metallic': 0.0,
                'specular': 0.1,
                'texture_scale': 1.0,
                'normal_strength': 0.8
            },
            {
                'temperature_sensitivity': 0.1,
                'humidity_sensitivity': 0.3,
                'aging_factor': 0.2,
                'stretch_recovery': 0.8,
                'compression_recovery': 0.8,
                'fatigue_resistance': 0.7,
                'abrasion_resistance': 0.6,
                'chemical_resistance': 0.5,
                'uv_resistance': 0.4,
                'flame_resistance': 0.6,
                'water_absorption': 0.8,
                'air_permeability': 0.9,
                'thermal_conductivity': 0.1,
                'biodegradability': 0.9,
                'recyclability': 0.8
            }
        )
        
        # 丝绸 - 光滑、柔软、有光泽
        silk = ClothMaterial(
            "Silk",
            ClothMaterial.TYPE_SILK,
            {
                'density': 0.3,
                'linear_stiffness': 0.5,
                'angular_stiffness': 0.4,
                'volume_stiffness': 0.2,
                'friction': 0.2,
                'restitution': 0.3,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.05,
                'lift_coefficient': 0.03,
                'bend_stiffness': 0.3,
                'damping': 0.005,
                'plastic_threshold': 0.05,
                'plastic_stiffness': 0.3,
                'tear_threshold': 80.0,
                'tear_resistance': 30.0,
                'anisotropic_friction': [0.2, 0.2, 0.2],
                'dynamic_friction': 0.2,
                'static_friction': 0.3,
                'rolling_friction': 0.05,
                'spinning_friction': 0.02,
                'viscosity': 0.005,
                'compressibility': 0.05,
                'shear_modulus': 0.4,
                'bulk_modulus': 0.9,
                'youngs_modulus': 0.6,
                'poisson_ratio': 0.35
            },
            {
                'color': Vec4(0.95, 0.95, 0.9, 1.0),
                'roughness': 0.3,
                'metallic': 0.1,
                'specular': 0.4,
                'texture_scale': 0.5,
                'normal_strength': 0.5,
                'sheen': 0.8,
                'sheen_roughness': 0.2
            },
            {
                'temperature_sensitivity': 0.05,
                'humidity_sensitivity': 0.2,
                'aging_factor': 0.1,
                'stretch_recovery': 0.9,
                'compression_recovery': 0.9,
                'fatigue_resistance': 0.6,
                'abrasion_resistance': 0.4,
                'chemical_resistance': 0.3,
                'uv_resistance': 0.2,
                'flame_resistance': 0.7,
                'water_absorption': 0.6,
                'air_permeability': 0.7,
                'thermal_conductivity': 0.05,
                'biodegradability': 0.8,
                'recyclability': 0.7
            }
        )
        
        # 皮革 - 坚韧、耐用
        leather = ClothMaterial(
            "Leather",
            ClothMaterial.TYPE_LEATHER,
            {
                'density': 0.8,
                'linear_stiffness': 0.9,
                'angular_stiffness': 0.8,
                'volume_stiffness': 0.6,
                'friction': 0.7,
                'restitution': 0.1,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.01,
                'lift_coefficient': 0.005,
                'bend_stiffness': 0.8,
                'damping': 0.015,
                'plastic_threshold': 0.2,
                'plastic_stiffness': 0.7,
                'tear_threshold': 150.0,
                'tear_resistance': 80.0,
                'anisotropic_friction': [0.7, 0.7, 0.7],
                'dynamic_friction': 0.7,
                'static_friction': 0.8,
                'rolling_friction': 0.15,
                'spinning_friction': 0.08,
                'viscosity': 0.015,
                'compressibility': 0.15,
                'shear_modulus': 0.8,
                'bulk_modulus': 1.1,
                'youngs_modulus': 0.85,
                'poisson_ratio': 0.42
            },
            {
                'color': Vec4(0.8, 0.6, 0.4, 1.0),
                'roughness': 0.6,
                'metallic': 0.0,
                'specular': 0.2,
                'texture_scale': 2.0,
                'normal_strength': 1.2
            },
            {
                'temperature_sensitivity': 0.02,
                'humidity_sensitivity': 0.1,
                'aging_factor': 0.05,
                'stretch_recovery': 0.7,
                'compression_recovery': 0.7,
                'fatigue_resistance': 0.9,
                'abrasion_resistance': 0.9,
                'chemical_resistance': 0.8,
                'uv_resistance': 0.7,
                'flame_resistance': 0.8,
                'water_absorption': 0.3,
                'air_permeability': 0.2,
                'thermal_conductivity': 0.15,
                'biodegradability': 0.4,
                'recyclability': 0.6
            }
        )
        
        # 橡胶 - 弹性、防水
        rubber = ClothMaterial(
            "Rubber",
            ClothMaterial.TYPE_RUBBER,
            {
                'density': 1.2,
                'linear_stiffness': 0.95,
                'angular_stiffness': 0.9,
                'volume_stiffness': 0.8,
                'friction': 0.8,
                'restitution': 0.4,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.005,
                'lift_coefficient': 0.002,
                'bend_stiffness': 0.9,
                'damping': 0.02,
                'plastic_threshold': 0.3,
                'plastic_stiffness': 0.8,
                'tear_threshold': 200.0,
                'tear_resistance': 100.0,
                'anisotropic_friction': [0.8, 0.8, 0.8],
                'dynamic_friction': 0.8,
                'static_friction': 0.9,
                'rolling_friction': 0.2,
                'spinning_friction': 0.1,
                'viscosity': 0.02,
                'compressibility': 0.2,
                'shear_modulus': 0.9,
                'bulk_modulus': 1.5,
                'youngs_modulus': 1.2,
                'poisson_ratio': 0.45
            },
            {
                'color': Vec4(0.3, 0.3, 0.3, 1.0),
                'roughness': 0.9,
                'metallic': 0.0,
                'specular': 0.1,
                'texture_scale': 0.3,
                'normal_strength': 0.3
            },
            {
                'temperature_sensitivity': 0.15,
                'humidity_sensitivity': 0.05,
                'aging_factor': 0.3,
                'stretch_recovery': 0.95,
                'compression_recovery': 0.95,
                'fatigue_resistance': 0.8,
                'abrasion_resistance': 0.7,
                'chemical_resistance': 0.9,
                'uv_resistance': 0.6,
                'flame_resistance': 0.9,
                'water_absorption': 0.1,
                'air_permeability': 0.0,
                'thermal_conductivity': 0.2,
                'biodegradability': 0.2,
                'recyclability': 0.5
            }
        )
        
        # 牛仔布 - 坚韧、耐磨
        denim = ClothMaterial(
            "Denim",
            ClothMaterial.TYPE_DENIM,
            {
                'density': 0.7,
                'linear_stiffness': 0.8,
                'angular_stiffness': 0.7,
                'volume_stiffness': 0.5,
                'friction': 0.65,
                'restitution': 0.15,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.015,
                'lift_coefficient': 0.008,
                'bend_stiffness': 0.6,
                'damping': 0.012,
                'plastic_threshold': 0.15,
                'plastic_stiffness': 0.6,
                'tear_threshold': 120.0,
                'tear_resistance': 60.0,
                'anisotropic_friction': [0.65, 0.65, 0.65],
                'dynamic_friction': 0.65,
                'static_friction': 0.75,
                'rolling_friction': 0.12,
                'spinning_friction': 0.06,
                'viscosity': 0.012,
                'compressibility': 0.12,
                'shear_modulus': 0.65,
                'bulk_modulus': 1.0,
                'youngs_modulus': 0.75,
                'poisson_ratio': 0.38
            },
            {
                'color': Vec4(0.4, 0.5, 0.7, 1.0),
                'roughness': 0.7,
                'metallic': 0.0,
                'specular': 0.15,
                'texture_scale': 1.5,
                'normal_strength': 1.0
            },
            {
                'temperature_sensitivity': 0.08,
                'humidity_sensitivity': 0.15,
                'aging_factor': 0.1,
                'stretch_recovery': 0.75,
                'compression_recovery': 0.75,
                'fatigue_resistance': 0.8,
                'abrasion_resistance': 0.8,
                'chemical_resistance': 0.6,
                'uv_resistance': 0.5,
                'flame_resistance': 0.7,
                'water_absorption': 0.4,
                'air_permeability': 0.6,
                'thermal_conductivity': 0.12,
                'biodegradability': 0.6,
                'recyclability': 0.7
            }
        )
        
        # 亚麻 - 天然、透气
        linen = ClothMaterial(
            "Linen",
            ClothMaterial.TYPE_LINEN,
            {
                'density': 0.5,
                'linear_stiffness': 0.6,
                'angular_stiffness': 0.5,
                'volume_stiffness': 0.3,
                'friction': 0.55,
                'restitution': 0.12,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.025,
                'lift_coefficient': 0.012,
                'bend_stiffness': 0.4,
                'damping': 0.008,
                'plastic_threshold': 0.12,
                'plastic_stiffness': 0.4,
                'tear_threshold': 90.0,
                'tear_resistance': 40.0,
                'anisotropic_friction': [0.55, 0.55, 0.55],
                'dynamic_friction': 0.55,
                'static_friction': 0.65,
                'rolling_friction': 0.08,
                'spinning_friction': 0.04,
                'viscosity': 0.008,
                'compressibility': 0.08,
                'shear_modulus': 0.5,
                'bulk_modulus': 0.8,
                'youngs_modulus': 0.6,
                'poisson_ratio': 0.35
            },
            {
                'color': Vec4(0.9, 0.85, 0.75, 1.0),
                'roughness': 0.85,
                'metallic': 0.0,
                'specular': 0.12,
                'texture_scale': 1.2,
                'normal_strength': 0.9
            },
            {
                'temperature_sensitivity': 0.12,
                'humidity_sensitivity': 0.25,
                'aging_factor': 0.15,
                'stretch_recovery': 0.7,
                'compression_recovery': 0.7,
                'fatigue_resistance': 0.6,
                'abrasion_resistance': 0.5,
                'chemical_resistance': 0.4,
                'uv_resistance': 0.3,
                'flame_resistance': 0.8,
                'water_absorption': 0.7,
                'air_permeability': 0.95,
                'thermal_conductivity': 0.08,
                'biodegradability': 0.95,
                'recyclability': 0.85
            }
        )
        
        # 羊毛 - 保暖、柔软
        wool = ClothMaterial(
            "Wool",
            ClothMaterial.TYPE_WOOL,
            {
                'density': 0.65,
                'linear_stiffness': 0.65,
                'angular_stiffness': 0.55,
                'volume_stiffness': 0.35,
                'friction': 0.6,
                'restitution': 0.13,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.018,
                'lift_coefficient': 0.009,
                'bend_stiffness': 0.45,
                'damping': 0.01,
                'plastic_threshold': 0.13,
                'plastic_stiffness': 0.45,
                'tear_threshold': 100.0,
                'tear_resistance': 50.0,
                'anisotropic_friction': [0.6, 0.6, 0.6],
                'dynamic_friction': 0.6,
                'static_friction': 0.7,
                'rolling_friction': 0.1,
                'spinning_friction': 0.05,
                'viscosity': 0.01,
                'compressibility': 0.18,
                'shear_modulus': 0.55,
                'bulk_modulus': 0.9,
                'youngs_modulus': 0.65,
                'poisson_ratio': 0.37
            },
            {
                'color': Vec4(0.85, 0.8, 0.7, 1.0),
                'roughness': 0.75,
                'metallic': 0.0,
                'specular': 0.13,
                'texture_scale': 1.8,
                'normal_strength': 1.1,
                'subsurface': 0.3,
                'subsurface_color': Vec4(0.9, 0.8, 0.7, 1.0)
            },
            {
                'temperature_sensitivity': 0.05,
                'humidity_sensitivity': 0.4,
                'aging_factor': 0.12,
                'stretch_recovery': 0.8,
                'compression_recovery': 0.8,
                'fatigue_resistance': 0.7,
                'abrasion_resistance': 0.6,
                'chemical_resistance': 0.5,
                'uv_resistance': 0.4,
                'flame_resistance': 0.9,
                'water_absorption': 0.6,
                'air_permeability': 0.7,
                'thermal_conductivity': 0.05,
                'biodegradability': 0.85,
                'recyclability': 0.75
            }
        )
        
        # 合成纤维 - 多功能性
        synthetic = ClothMaterial(
            "Synthetic",
            ClothMaterial.TYPE_SYNTHETIC,
            {
                'density': 0.4,
                'linear_stiffness': 0.75,
                'angular_stiffness': 0.65,
                'volume_stiffness': 0.45,
                'friction': 0.5,
                'restitution': 0.2,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.012,
                'lift_coefficient': 0.007,
                'bend_stiffness': 0.55,
                'damping': 0.006,
                'plastic_threshold': 0.18,
                'plastic_stiffness': 0.55,
                'tear_threshold': 110.0,
                'tear_resistance': 55.0,
                'anisotropic_friction': [0.5, 0.5, 0.5],
                'dynamic_friction': 0.5,
                'static_friction': 0.6,
                'rolling_friction': 0.07,
                'spinning_friction': 0.03,
                'viscosity': 0.006,
                'compressibility': 0.1,
                'shear_modulus': 0.55,
                'bulk_modulus': 0.95,
                'youngs_modulus': 0.7,
                'poisson_ratio': 0.39
            },
            {
                'color': Vec4(0.7, 0.7, 0.7, 1.0),
                'roughness': 0.5,
                'metallic': 0.05,
                'specular': 0.25,
                'texture_scale': 1.0,
                'normal_strength': 0.7
            },
            {
                'temperature_sensitivity': 0.08,
                'humidity_sensitivity': 0.1,
                'aging_factor': 0.08,
                'stretch_recovery': 0.85,
                'compression_recovery': 0.85,
                'fatigue_resistance': 0.85,
                'abrasion_resistance': 0.75,
                'chemical_resistance': 0.85,
                'uv_resistance': 0.75,
                'flame_resistance': 0.6,
                'water_absorption': 0.2,
                'air_permeability': 0.6,
                'thermal_conductivity': 0.15,
                'biodegradability': 0.3,
                'recyclability': 0.9
            }
        )
        
        # 网眼布 - 透气、轻质
        mesh = ClothMaterial(
            "Mesh",
            ClothMaterial.TYPE_MESH,
            {
                'density': 0.2,
                'linear_stiffness': 0.4,
                'angular_stiffness': 0.3,
                'volume_stiffness': 0.1,
                'friction': 0.3,
                'restitution': 0.05,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.04,
                'lift_coefficient': 0.02,
                'bend_stiffness': 0.2,
                'damping': 0.003,
                'plastic_threshold': 0.08,
                'plastic_stiffness': 0.2,
                'tear_threshold': 70.0,
                'tear_resistance': 25.0,
                'anisotropic_friction': [0.3, 0.3, 0.3],
                'dynamic_friction': 0.3,
                'static_friction': 0.4,
                'rolling_friction': 0.03,
                'spinning_friction': 0.01,
                'viscosity': 0.003,
                'compressibility': 0.05,
                'shear_modulus': 0.2,
                'bulk_modulus': 0.5,
                'youngs_modulus': 0.3,
                'poisson_ratio': 0.3
            },
            {
                'color': Vec4(0.6, 0.6, 0.6, 0.7),
                'roughness': 0.6,
                'metallic': 0.1,
                'specular': 0.2,
                'texture_scale': 3.0,
                'normal_strength': 0.4,
                'opacity': 0.7
            },
            {
                'temperature_sensitivity': 0.03,
                'humidity_sensitivity': 0.05,
                'aging_factor': 0.03,
                'stretch_recovery': 0.9,
                'compression_recovery': 0.9,
                'fatigue_resistance': 0.5,
                'abrasion_resistance': 0.3,
                'chemical_resistance': 0.7,
                'uv_resistance': 0.6,
                'flame_resistance': 0.8,
                'water_absorption': 0.1,
                'air_permeability': 1.0,
                'thermal_conductivity': 0.2,
                'biodegradability': 0.4,
                'recyclability': 0.95
            }
        )
        
        # 帆布 - 坚固、耐用
        canvas = ClothMaterial(
            "Canvas",
            ClothMaterial.TYPE_CANVAS,
            {
                'density': 0.75,
                'linear_stiffness': 0.85,
                'angular_stiffness': 0.75,
                'volume_stiffness': 0.55,
                'friction': 0.68,
                'restitution': 0.14,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.013,
                'lift_coefficient': 0.006,
                'bend_stiffness': 0.65,
                'damping': 0.014,
                'plastic_threshold': 0.18,
                'plastic_stiffness': 0.65,
                'tear_threshold': 130.0,
                'tear_resistance': 65.0,
                'anisotropic_friction': [0.68, 0.68, 0.68],
                'dynamic_friction': 0.68,
                'static_friction': 0.78,
                'rolling_friction': 0.14,
                'spinning_friction': 0.07,
                'viscosity': 0.014,
                'compressibility': 0.14,
                'shear_modulus': 0.65,
                'bulk_modulus': 1.05,
                'youngs_modulus': 0.8,
                'poisson_ratio': 0.4
            },
            {
                'color': Vec4(0.8, 0.75, 0.65, 1.0),
                'roughness': 0.78,
                'metallic': 0.0,
                'specular': 0.14,
                'texture_scale': 2.5,
                'normal_strength': 1.3
            },
            {
                'temperature_sensitivity': 0.06,
                'humidity_sensitivity': 0.2,
                'aging_factor': 0.08,
                'stretch_recovery': 0.78,
                'compression_recovery': 0.78,
                'fatigue_resistance': 0.85,
                'abrasion_resistance': 0.85,
                'chemical_resistance': 0.7,
                'uv_resistance': 0.6,
                'flame_resistance': 0.75,
                'water_absorption': 0.35,
                'air_permeability': 0.5,
                'thermal_conductivity': 0.13,
                'biodegradability': 0.5,
                'recyclability': 0.7
            }
        )
        
        # 尼龙 - 强韧、轻质
        nylon = ClothMaterial(
            "Nylon",
            ClothMaterial.TYPE_NYLON,
            {
                'density': 0.35,
                'linear_stiffness': 0.8,
                'angular_stiffness': 0.7,
                'volume_stiffness': 0.5,
                'friction': 0.4,
                'restitution': 0.25,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.01,
                'lift_coefficient': 0.005,
                'bend_stiffness': 0.6,
                'damping': 0.007,
                'plastic_threshold': 0.15,
                'plastic_stiffness': 0.6,
                'tear_threshold': 140.0,
                'tear_resistance': 70.0,
                'anisotropic_friction': [0.4, 0.4, 0.4],
                'dynamic_friction': 0.4,
                'static_friction': 0.5,
                'rolling_friction': 0.08,
                'spinning_friction': 0.04,
                'viscosity': 0.007,
                'compressibility': 0.08,
                'shear_modulus': 0.6,
                'bulk_modulus': 1.0,
                'youngs_modulus': 0.85,
                'poisson_ratio': 0.4
            },
            {
                'color': Vec4(0.95, 0.95, 0.95, 1.0),
                'roughness': 0.4,
                'metallic': 0.0,
                'specular': 0.3,
                'texture_scale': 1.0,
                'normal_strength': 0.6
            },
            {
                'temperature_sensitivity': 0.1,
                'humidity_sensitivity': 0.15,
                'aging_factor': 0.1,
                'stretch_recovery': 0.92,
                'compression_recovery': 0.92,
                'fatigue_resistance': 0.88,
                'abrasion_resistance': 0.8,
                'chemical_resistance': 0.8,
                'uv_resistance': 0.5,
                'flame_resistance': 0.65,
                'water_absorption': 0.25,
                'air_permeability': 0.65,
                'thermal_conductivity': 0.18,
                'biodegradability': 0.25,
                'recyclability': 0.85
            }
        )
        
        # 聚酯纤维 - 耐用、抗皱
        polyester = ClothMaterial(
            "Polyester",
            ClothMaterial.TYPE_POLYESTER,
            {
                'density': 0.45,
                'linear_stiffness': 0.7,
                'angular_stiffness': 0.6,
                'volume_stiffness': 0.4,
                'friction': 0.45,
                'restitution': 0.18,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.015,
                'lift_coefficient': 0.008,
                'bend_stiffness': 0.5,
                'damping': 0.009,
                'plastic_threshold': 0.12,
                'plastic_stiffness': 0.5,
                'tear_threshold': 110.0,
                'tear_resistance': 55.0,
                'anisotropic_friction': [0.45, 0.45, 0.45],
                'dynamic_friction': 0.45,
                'static_friction': 0.55,
                'rolling_friction': 0.09,
                'spinning_friction': 0.045,
                'viscosity': 0.009,
                'compressibility': 0.1,
                'shear_modulus': 0.55,
                'bulk_modulus': 0.95,
                'youngs_modulus': 0.75,
                'poisson_ratio': 0.38
            },
            {
                'color': Vec4(0.8, 0.8, 0.8, 1.0),
                'roughness': 0.55,
                'metallic': 0.0,
                'specular': 0.2,
                'texture_scale': 1.0,
                'normal_strength': 0.7
            },
            {
                'temperature_sensitivity': 0.07,
                'humidity_sensitivity': 0.08,
                'aging_factor': 0.06,
                'stretch_recovery': 0.88,
                'compression_recovery': 0.88,
                'fatigue_resistance': 0.82,
                'abrasion_resistance': 0.75,
                'chemical_resistance': 0.85,
                'uv_resistance': 0.65,
                'flame_resistance': 0.7,
                'water_absorption': 0.15,
                'air_permeability': 0.55,
                'thermal_conductivity': 0.14,
                'biodegradability': 0.15,
                'recyclability': 0.9
            }
        )
        
        # 缎子 - 光滑、有光泽
        satin = ClothMaterial(
            "Satin",
            ClothMaterial.TYPE_SATIN,
            {
                'density': 0.25,
                'linear_stiffness': 0.45,
                'angular_stiffness': 0.35,
                'volume_stiffness': 0.25,
                'friction': 0.15,
                'restitution': 0.28,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.03,
                'lift_coefficient': 0.015,
                'bend_stiffness': 0.3,
                'damping': 0.004,
                'plastic_threshold': 0.08,
                'plastic_stiffness': 0.3,
                'tear_threshold': 75.0,
                'tear_resistance': 35.0,
                'anisotropic_friction': [0.15, 0.15, 0.15],
                'dynamic_friction': 0.15,
                'static_friction': 0.25,
                'rolling_friction': 0.04,
                'spinning_friction': 0.02,
                'viscosity': 0.004,
                'compressibility': 0.06,
                'shear_modulus': 0.35,
                'bulk_modulus': 0.7,
                'youngs_modulus': 0.5,
                'poisson_ratio': 0.33
            },
            {
                'color': Vec4(0.98, 0.98, 0.98, 1.0),
                'roughness': 0.1,
                'metallic': 0.2,
                'specular': 0.6,
                'texture_scale': 0.8,
                'normal_strength': 0.3,
                'sheen': 0.9,
                'sheen_roughness': 0.1
            },
            {
                'temperature_sensitivity': 0.04,
                'humidity_sensitivity': 0.12,
                'aging_factor': 0.08,
                'stretch_recovery': 0.85,
                'compression_recovery': 0.85,
                'fatigue_resistance': 0.65,
                'abrasion_resistance': 0.45,
                'chemical_resistance': 0.6,
                'uv_resistance': 0.3,
                'flame_resistance': 0.75,
                'water_absorption': 0.3,
                'air_permeability': 0.4,
                'thermal_conductivity': 0.07,
                'biodegradability': 0.5,
                'recyclability': 0.75
            }
        )
        
        # 毛圈织物 - 吸水、柔软
        terry = ClothMaterial(
            "Terry",
            ClothMaterial.TYPE_TERRY,
            {
                'density': 0.55,
                'linear_stiffness': 0.55,
                'angular_stiffness': 0.45,
                'volume_stiffness': 0.3,
                'friction': 0.5,
                'restitution': 0.1,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.02,
                'lift_coefficient': 0.01,
                'bend_stiffness': 0.35,
                'damping': 0.012,
                'plastic_threshold': 0.1,
                'plastic_stiffness': 0.35,
                'tear_threshold': 95.0,
                'tear_resistance': 45.0,
                'anisotropic_friction': [0.5, 0.5, 0.5],
                'dynamic_friction': 0.5,
                'static_friction': 0.6,
                'rolling_friction': 0.1,
                'spinning_friction': 0.05,
                'viscosity': 0.012,
                'compressibility': 0.15,
                'shear_modulus': 0.45,
                'bulk_modulus': 0.85,
                'youngs_modulus': 0.6,
                'poisson_ratio': 0.36
            },
            {
                'color': Vec4(0.92, 0.92, 0.92, 1.0),
                'roughness': 0.8,
                'metallic': 0.0,
                'specular': 0.15,
                'texture_scale': 2.0,
                'normal_strength': 1.5,
                'subsurface': 0.2,
                'subsurface_color': Vec4(0.95, 0.95, 0.95, 1.0)
            },
            {
                'temperature_sensitivity': 0.09,
                'humidity_sensitivity': 0.35,
                'aging_factor': 0.13,
                'stretch_recovery': 0.75,
                'compression_recovery': 0.75,
                'fatigue_resistance': 0.65,
                'abrasion_resistance': 0.55,
                'chemical_resistance': 0.5,
                'uv_resistance': 0.45,
                'flame_resistance': 0.8,
                'water_absorption': 0.9,
                'air_permeability': 0.75,
                'thermal_conductivity': 0.1,
                'biodegradability': 0.7,
                'recyclability': 0.8
            }
        )
        
        # 抓绒 - 保暖、柔软
        fleece = ClothMaterial(
            "Fleece",
            ClothMaterial.TYPE_FLEECE,
            {
                'density': 0.3,
                'linear_stiffness': 0.4,
                'angular_stiffness': 0.3,
                'volume_stiffness': 0.2,
                'friction': 0.4,
                'restitution': 0.08,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.025,
                'lift_coefficient': 0.012,
                'bend_stiffness': 0.25,
                'damping': 0.008,
                'plastic_threshold': 0.07,
                'plastic_stiffness': 0.25,
                'tear_threshold': 80.0,
                'tear_resistance': 35.0,
                'anisotropic_friction': [0.4, 0.4, 0.4],
                'dynamic_friction': 0.4,
                'static_friction': 0.5,
                'rolling_friction': 0.08,
                'spinning_friction': 0.04,
                'viscosity': 0.008,
                'compressibility': 0.2,
                'shear_modulus': 0.3,
                'bulk_modulus': 0.6,
                'youngs_modulus': 0.4,
                'poisson_ratio': 0.32
            },
            {
                'color': Vec4(0.88, 0.88, 0.88, 1.0),
                'roughness': 0.85,
                'metallic': 0.0,
                'specular': 0.1,
                'texture_scale': 1.5,
                'normal_strength': 1.8,
                'subsurface': 0.4,
                'subsurface_color': Vec4(0.9, 0.9, 0.9, 1.0)
            },
            {
                'temperature_sensitivity': 0.06,
                'humidity_sensitivity': 0.25,
                'aging_factor': 0.1,
                'stretch_recovery': 0.8,
                'compression_recovery': 0.8,
                'fatigue_resistance': 0.6,
                'abrasion_resistance': 0.5,
                'chemical_resistance': 0.6,
                'uv_resistance': 0.5,
                'flame_resistance': 0.85,
                'water_absorption': 0.5,
                'air_permeability': 0.65,
                'thermal_conductivity': 0.04,
                'biodegradability': 0.6,
                'recyclability': 0.85
            }
        )
        
        # 氯丁橡胶 - 防水、保温
        neoprene = ClothMaterial(
            "Neoprene",
            ClothMaterial.TYPE_NEOPRENE,
            {
                'density': 0.9,
                'linear_stiffness': 0.85,
                'angular_stiffness': 0.75,
                'volume_stiffness': 0.65,
                'friction': 0.6,
                'restitution': 0.22,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.008,
                'lift_coefficient': 0.003,
                'bend_stiffness': 0.7,
                'damping': 0.018,
                'plastic_threshold': 0.25,
                'plastic_stiffness': 0.7,
                'tear_threshold': 160.0,
                'tear_resistance': 85.0,
                'anisotropic_friction': [0.6, 0.6, 0.6],
                'dynamic_friction': 0.6,
                'static_friction': 0.7,
                'rolling_friction': 0.16,
                'spinning_friction': 0.09,
                'viscosity': 0.018,
                'compressibility': 0.18,
                'shear_modulus': 0.75,
                'bulk_modulus': 1.2,
                'youngs_modulus': 0.9,
                'poisson_ratio': 0.43
            },
            {
                'color': Vec4(0.2, 0.2, 0.2, 1.0),
                'roughness': 0.7,
                'metallic': 0.0,
                'specular': 0.25,
                'texture_scale': 0.5,
                'normal_strength': 0.8
            },
            {
                'temperature_sensitivity': 0.12,
                'humidity_sensitivity': 0.03,
                'aging_factor': 0.15,
                'stretch_recovery': 0.9,
                'compression_recovery': 0.9,
                'fatigue_resistance': 0.85,
                'abrasion_resistance': 0.75,
                'chemical_resistance': 0.95,
                'uv_resistance': 0.7,
                'flame_resistance': 0.8,
                'water_absorption': 0.05,
                'air_permeability': 0.0,
                'thermal_conductivity': 0.12,
                'biodegradability': 0.1,
                'recyclability': 0.6
            }
        )
        
        # 氨纶 - 高弹性
        spandex = ClothMaterial(
            "Spandex",
            ClothMaterial.TYPE_SPANDEX,
            {
                'density': 0.2,
                'linear_stiffness': 0.3,
                'angular_stiffness': 0.25,
                'volume_stiffness': 0.15,
                'friction': 0.35,
                'restitution': 0.35,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.018,
                'lift_coefficient': 0.009,
                'bend_stiffness': 0.2,
                'damping': 0.005,
                'plastic_threshold': 0.05,
                'plastic_stiffness': 0.2,
                'tear_threshold': 60.0,
                'tear_resistance': 20.0,
                'anisotropic_friction': [0.35, 0.35, 0.35],
                'dynamic_friction': 0.35,
                'static_friction': 0.45,
                'rolling_friction': 0.06,
                'spinning_friction': 0.03,
                'viscosity': 0.005,
                'compressibility': 0.07,
                'shear_modulus': 0.25,
                'bulk_modulus': 0.55,
                'youngs_modulus': 0.35,
                'poisson_ratio': 0.31
            },
            {
                'color': Vec4(0.95, 0.95, 0.95, 1.0),
                'roughness': 0.45,
                'metallic': 0.0,
                'specular': 0.35,
                'texture_scale': 0.8,
                'normal_strength': 0.4
            },
            {
                'temperature_sensitivity': 0.08,
                'humidity_sensitivity': 0.07,
                'aging_factor': 0.05,
                'stretch_recovery': 0.98,
                'compression_recovery': 0.98,
                'fatigue_resistance': 0.75,
                'abrasion_resistance': 0.4,
                'chemical_resistance': 0.7,
                'uv_resistance': 0.4,
                'flame_resistance': 0.6,
                'water_absorption': 0.1,
                'air_permeability': 0.5,
                'thermal_conductivity': 0.16,
                'biodegradability': 0.2,
                'recyclability': 0.7
            }
        )
        
        # 粗花呢 - 厚重、有纹理
        tweed = ClothMaterial(
            "Tweed",
            ClothMaterial.TYPE_TWEED,
            {
                'density': 0.7,
                'linear_stiffness': 0.75,
                'angular_stiffness': 0.65,
                'volume_stiffness': 0.45,
                'friction': 0.62,
                'restitution': 0.12,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.014,
                'lift_coefficient': 0.007,
                'bend_stiffness': 0.55,
                'damping': 0.013,
                'plastic_threshold': 0.14,
                'plastic_stiffness': 0.55,
                'tear_threshold': 115.0,
                'tear_resistance': 58.0,
                'anisotropic_friction': [0.62, 0.62, 0.62],
                'dynamic_friction': 0.62,
                'static_friction': 0.72,
                'rolling_friction': 0.13,
                'spinning_friction': 0.065,
                'viscosity': 0.013,
                'compressibility': 0.13,
                'shear_modulus': 0.58,
                'bulk_modulus': 0.98,
                'youngs_modulus': 0.72,
                'poisson_ratio': 0.39
            },
            {
                'color': Vec4(0.75, 0.7, 0.6, 1.0),
                'roughness': 0.72,
                'metallic': 0.0,
                'specular': 0.16,
                'texture_scale': 3.0,
                'normal_strength': 1.4
            },
            {
                'temperature_sensitivity': 0.07,
                'humidity_sensitivity': 0.18,
                'aging_factor': 0.09,
                'stretch_recovery': 0.72,
                'compression_recovery': 0.72,
                'fatigue_resistance': 0.78,
                'abrasion_resistance': 0.72,
                'chemical_resistance': 0.65,
                'uv_resistance': 0.55,
                'flame_resistance': 0.72,
                'water_absorption': 0.32,
                'air_permeability': 0.58,
                'thermal_conductivity': 0.11,
                'biodegradability': 0.55,
                'recyclability': 0.72
            }
        )
        
        # 薄纱 - 轻盈、透明
        tulle = ClothMaterial(
            "Tulle",
            ClothMaterial.TYPE_TULLE,
            {
                'density': 0.1,
                'linear_stiffness': 0.25,
                'angular_stiffness': 0.2,
                'volume_stiffness': 0.1,
                'friction': 0.2,
                'restitution': 0.15,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.035,
                'lift_coefficient': 0.018,
                'bend_stiffness': 0.15,
                'damping': 0.003,
                'plastic_threshold': 0.04,
                'plastic_stiffness': 0.15,
                'tear_threshold': 40.0,
                'tear_resistance': 15.0,
                'anisotropic_friction': [0.2, 0.2, 0.2],
                'dynamic_friction': 0.2,
                'static_friction': 0.3,
                'rolling_friction': 0.03,
                'spinning_friction': 0.015,
                'viscosity': 0.003,
                'compressibility': 0.03,
                'shear_modulus': 0.15,
                'bulk_modulus': 0.3,
                'youngs_modulus': 0.2,
                'poisson_ratio': 0.3
            },
            {
                'color': Vec4(1.0, 1.0, 1.0, 0.3),
                'roughness': 0.5,
                'metallic': 0.0,
                'specular': 0.4,
                'texture_scale': 4.0,
                'normal_strength': 0.2,
                'opacity': 0.3
            },
            {
                'temperature_sensitivity': 0.02,
                'humidity_sensitivity': 0.04,
                'aging_factor': 0.02,
                'stretch_recovery': 0.95,
                'compression_recovery': 0.95,
                'fatigue_resistance': 0.4,
                'abrasion_resistance': 0.2,
                'chemical_resistance': 0.5,
                'uv_resistance': 0.4,
                'flame_resistance': 0.9,
                'water_absorption': 0.05,
                'air_permeability': 1.0,
                'thermal_conductivity': 0.25,
                'biodegradability': 0.6,
                'recyclability': 0.98
            }
        )
        
        # 天鹅绒 - 柔软、有光泽
        velvet = ClothMaterial(
            "Velvet",
            ClothMaterial.TYPE_VELVET,
            {
                'density': 0.6,
                'linear_stiffness': 0.5,
                'angular_stiffness': 0.4,
                'volume_stiffness': 0.3,
                'friction': 0.45,
                'restitution': 0.1,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.022,
                'lift_coefficient': 0.011,
                'bend_stiffness': 0.35,
                'damping': 0.011,
                'plastic_threshold': 0.09,
                'plastic_stiffness': 0.35,
                'tear_threshold': 85.0,
                'tear_resistance': 40.0,
                'anisotropic_friction': [0.45, 0.45, 0.45],
                'dynamic_friction': 0.45,
                'static_friction': 0.55,
                'rolling_friction': 0.09,
                'spinning_friction': 0.045,
                'viscosity': 0.011,
                'compressibility': 0.11,
                'shear_modulus': 0.4,
                'bulk_modulus': 0.75,
                'youngs_modulus': 0.55,
                'poisson_ratio': 0.35
            },
            {
                'color': Vec4(0.85, 0.8, 0.75, 1.0),
                'roughness': 0.2,
                'metallic': 0.3,
                'specular': 0.5,
                'texture_scale': 1.2,
                'normal_strength': 2.0,
                'sheen': 0.7,
                'sheen_roughness': 0.15
            },
            {
                'temperature_sensitivity': 0.06,
                'humidity_sensitivity': 0.22,
                'aging_factor': 0.11,
                'stretch_recovery': 0.82,
                'compression_recovery': 0.82,
                'fatigue_resistance': 0.68,
                'abrasion_resistance': 0.52,
                'chemical_resistance': 0.58,
                'uv_resistance': 0.48,
                'flame_resistance': 0.78,
                'water_absorption': 0.42,
                'air_permeability': 0.62,
                'thermal_conductivity': 0.09,
                'biodegradability': 0.62,
                'recyclability': 0.78
            }
        )
        
        # 翻毛皮 - 柔软、有质感
        suede = ClothMaterial(
            "Suede",
            ClothMaterial.TYPE_SUEDE,
            {
                'density': 0.75,
                'linear_stiffness': 0.65,
                'angular_stiffness': 0.55,
                'volume_stiffness': 0.4,
                'friction': 0.55,
                'restitution': 0.08,
                'pressure_coefficient': 0.0,
                'drag_coefficient': 0.016,
                'lift_coefficient': 0.008,
                'bend_stiffness': 0.45,
                'damping': 0.015,
                'plastic_threshold': 0.11,
                'plastic_stiffness': 0.45,
                'tear_threshold': 105.0,
                'tear_resistance': 52.0,
                'anisotropic_friction': [0.55, 0.55, 0.55],
                'dynamic_friction': 0.55,
                'static_friction': 0.65,
                'rolling_friction': 0.11,
                'spinning_friction': 0.055,
                'viscosity': 0.015,
                'compressibility': 0.12,
                'shear_modulus': 0.48,
                'bulk_modulus': 0.9,
                'youngs_modulus': 0.68,
                'poisson_ratio': 0.37
            },
            {
                'color': Vec4(0.7, 0.65, 0.6, 1.0),
                'roughness': 0.85,
                'metallic': 0.0,
                'specular': 0.18,
                'texture_scale': 2.2,
                'normal_strength': 1.6
            },
            {
                'temperature_sensitivity': 0.05,
                'humidity_sensitivity': 0.16,
                'aging_factor': 0.07,
                'stretch_recovery': 0.76,
                'compression_recovery': 0.76,
                'fatigue_resistance': 0.72,
                'abrasion_resistance': 0.62,
                'chemical_resistance': 0.68,
                'uv_resistance': 0.58,
                'flame_resistance': 0.76,
                'water_absorption': 0.38,
                'air_permeability': 0.52,
                'thermal_conductivity': 0.13,
                'biodegradability': 0.48,
                'recyclability': 0.68
            }
        )
        
        # 添加到材质字典
        self.materials = {
            ClothMaterial.TYPE_COTTON: cotton,
            ClothMaterial.TYPE_SILK: silk,
            ClothMaterial.TYPE_LEATHER: leather,
            ClothMaterial.TYPE_RUBBER: rubber,
            ClothMaterial.TYPE_DENIM: denim,
            ClothMaterial.TYPE_LINEN: linen,
            ClothMaterial.TYPE_WOOL: wool,
            ClothMaterial.TYPE_SYNTHETIC: synthetic,
            ClothMaterial.TYPE_MESH: mesh,
            ClothMaterial.TYPE_CANVAS: canvas,
            ClothMaterial.TYPE_NYLON: nylon,
            ClothMaterial.TYPE_POLYESTER: polyester,
            ClothMaterial.TYPE_SATIN: satin,
            ClothMaterial.TYPE_TERRY: terry,
            ClothMaterial.TYPE_FLEECE: fleece,
            ClothMaterial.TYPE_NEOPRENE: neoprene,
            ClothMaterial.TYPE_SPANDEX: spandex,
            ClothMaterial.TYPE_TWEED: tweed,
            ClothMaterial.TYPE_TULLE: tulle,
            ClothMaterial.TYPE_VELVET: velvet,
            ClothMaterial.TYPE_SUEDE: suede
        }
        
    def get_material(self, material_type: str) -> Optional[ClothMaterial]:
        """
        获取指定类型的布料材质
        
        Args:
            material_type: 材质类型
            
        Returns:
            布料材质对象或None
        """
        return self.materials.get(material_type)
        
    def get_all_material_types(self) -> List[str]:
        """
        获取所有材质类型
        
        Returns:
            材质类型列表
        """
        return list(self.materials.keys())
        
    def get_material_names(self) -> List[str]:
        """
        获取所有材质名称
        
        Returns:
            材质名称列表
        """
        return [material.name for material in self.materials.values()]
        
    def create_custom_material(self, name: str, material_type: str,
                             physical_params: Dict[str, float] = None,
                             visual_params: Dict[str, Any] = None,
                             advanced_params: Dict[str, Any] = None) -> ClothMaterial:
        """
        创建自定义布料材质
        
        Args:
            name: 材质名称
            material_type: 材质类型
            physical_params: 物理参数
            visual_params: 视觉参数
            advanced_params: 高级参数
            
        Returns:
            布料材质对象
        """
        material = ClothMaterial(name, material_type, physical_params, visual_params, advanced_params)
        return material
        
    def register_material(self, material: ClothMaterial) -> bool:
        """
        注册布料材质
        
        Args:
            material: 布料材质对象
            
        Returns:
            是否注册成功
        """
        if material.material_type:
            self.materials[material.material_type] = material
            return True
        return False
        
    def create_material_combination(self, name: str, materials: List[str], 
                                  ratios: List[float]) -> ClothMaterial:
        """
        创建混合材质
        
        Args:
            name: 混合材质名称
            materials: 材质类型列表
            ratios: 比例列表
            
        Returns:
            混合布料材质对象
        """
        if len(materials) != len(ratios):
            raise ValueError("材质数量和比例数量必须相同")
            
        # 归一化比例
        total_ratio = sum(ratios)
        if total_ratio == 0:
            raise ValueError("比例总和不能为0")
        normalized_ratios = [r / total_ratio for r in ratios]
        
        # 获取所有材质
        material_objects = []
        for material_type in materials:
            material_obj = self.get_material(material_type)
            if material_obj is None:
                raise ValueError(f"未知材质类型: {material_type}")
            material_objects.append(material_obj)
            
        # 混合物理参数
        combined_physical = {}
        combined_visual = {}
        combined_advanced = {}
        
        # 物理参数混合
        for param_name in material_objects[0].physical_params.keys():
            weighted_sum = 0.0
            for i, material_obj in enumerate(material_objects):
                weighted_sum += material_obj.physical_params[param_name] * normalized_ratios[i]
            combined_physical[param_name] = weighted_sum
            
        # 视觉参数混合
        for param_name in material_objects[0].visual_params.keys():
            if param_name == 'color':
                # 颜色混合
                mixed_color = Vec4(0, 0, 0, 0)
                for i, material_obj in enumerate(material_objects):
                    color = material_obj.visual_params[param_name]
                    mixed_color += color * normalized_ratios[i]
                combined_visual[param_name] = mixed_color
            else:
                # 其他视觉参数混合
                weighted_sum = 0.0
                for i, material_obj in enumerate(material_objects):
                    weighted_sum += material_obj.visual_params[param_name] * normalized_ratios[i]
                combined_visual[param_name] = weighted_sum
                
        # 高级参数混合
        for param_name in material_objects[0].advanced_params.keys():
            weighted_sum = 0.0
            for i, material_obj in enumerate(material_objects):
                weighted_sum += material_obj.advanced_params[param_name] * normalized_ratios[i]
            combined_advanced[param_name] = weighted_sum
            
        # 创建混合材质
        combined_material = ClothMaterial(
            name, 
            f"combined_{name}",
            combined_physical,
            combined_visual,
            combined_advanced
        )
        
        # 保存组合信息
        self.material_combinations[name] = {
            'materials': materials,
            'ratios': normalized_ratios,
            'material_object': combined_material
        }
        
        return combined_material
        
    def get_material_combination(self, name: str) -> Optional[ClothMaterial]:
        """
        获取混合材质
        
        Args:
            name: 混合材质名称
            
        Returns:
            混合布料材质对象或None
        """
        combination = self.material_combinations.get(name)
        if combination:
            return combination['material_object']
        return None
        
    def get_material_properties_database(self) -> Dict[str, Dict[str, Any]]:
        """
        获取材质属性数据库
        
        Returns:
            材质属性字典
        """
        database = {}
        for material_type, material in self.materials.items():
            database[material_type] = material.get_material_properties_summary()
        return database
        
    def find_similar_materials(self, reference_material: ClothMaterial, 
                             max_results: int = 5) -> List[Tuple[str, float]]:
        """
        查找相似材质
        
        Args:
            reference_material: 参考材质
            max_results: 最大结果数量
            
        Returns:
            相似材质列表 (材质类型, 相似度)
        """
        reference_props = reference_material.get_material_properties_summary()
        similarities = []
        
        for material_type, material in self.materials.items():
            if material_type == reference_material.material_type:
                continue  # 跳过自身
                
            material_props = material.get_material_properties_summary()
            
            # 计算相似度 (简化版本)
            similarity = 0.0
            total_weight = 0.0
            
            # 物理属性相似度
            ref_phys = reference_props['physical_properties']
            mat_phys = material_props['physical_properties']
            
            for key in ref_phys.keys():
                if key in mat_phys:
                    ref_val = ref_phys[key]
                    mat_val = mat_phys[key]
                    # 归一化差异 (假设值在合理范围内)
                    diff = abs(ref_val - mat_val) / max(1.0, ref_val + mat_val)
                    similarity += (1.0 - diff) * 0.4
                    total_weight += 0.4
                    
            # 视觉属性相似度
            ref_vis = reference_props['visual_properties']
            mat_vis = material_props['visual_properties']
            
            # 颜色相似度
            if 'color' in ref_vis and 'color' in mat_vis:
                ref_color = ref_vis['color']
                mat_color = mat_vis['color']
                color_diff = (
                    (ref_color[0] - mat_color[0]) ** 2 +
                    (ref_color[1] - mat_color[1]) ** 2 +
                    (ref_color[2] - mat_color[2]) ** 2
                ) ** 0.5
                similarity += (1.0 - color_diff) * 0.3
                total_weight += 0.3
                
            # 粗糙度相似度
            if 'roughness' in ref_vis and 'roughness' in mat_vis:
                roughness_diff = abs(ref_vis['roughness'] - mat_vis['roughness'])
                similarity += (1.0 - roughness_diff) * 0.2
                total_weight += 0.2
                
            # 金属度相似度
            if 'metallic' in ref_vis and 'metallic' in mat_vis:
                metallic_diff = abs(ref_vis['metallic'] - mat_vis['metallic'])
                similarity += (1.0 - metallic_diff) * 0.1
                total_weight += 0.1
                
            if total_weight > 0:
                normalized_similarity = similarity / total_weight
                similarities.append((material_type, normalized_similarity))
                
        # 按相似度排序
        similarities.sort(key=lambda x: x[1], reverse=True)
        return similarities[:max_results]