diff --git a/RenderPipelineFile/start_plugin_configurator.py b/RenderPipelineFile/start_plugin_configurator.py index 6ac56335..cbfd9ec5 100644 --- a/RenderPipelineFile/start_plugin_configurator.py +++ b/RenderPipelineFile/start_plugin_configurator.py @@ -9,4 +9,5 @@ if not os.path.isfile(os.path.join(this_dir, "data", "install.flag")): print("Please install the pipeline first by running setup.py") sys.exit(-1) to_execute = os.path.join(this_dir, "toolkit", "plugin_configurator", "main.py") -subprocess.call([sys.executable, to_execute]) +# 使用相对路径而不是绝对路径 +subprocess.call([sys.executable, to_execute], cwd=this_dir) \ No newline at end of file diff --git a/core/selection.py b/core/selection.py index 54042e41..75fb874f 100644 --- a/core/selection.py +++ b/core/selection.py @@ -436,12 +436,12 @@ class SelectionSystem: print(f"✓ 添加core目录到模型搜索路径: {core_dir}") if is_scale_tool: - model_path = "core/UniformScaleHandle.fbx" + model_filename = "core/UniformScaleHandle.fbx" elif is_rotate_tool: - model_path = "core/RotationHandleQuarter.fbx" - arrow_path = "core/TranslateArrowHandle.fbx" + model_filename = "core/RotationHandleQuarter.fbx" + arrow_filename = "core/TranslateArrowHandle.fbx" else: - model_path = "core/TranslateArrowHandle.fbx" + model_filename = "core/TranslateArrowHandle.fbx" # model_paths = [ # "core/TranslateArrowHandle.fbx", @@ -451,10 +451,10 @@ class SelectionSystem: gizmoRot_model = None try: if is_rotate_tool: - gizmo_model = self.world.loader.loadModel(arrow_path) - gizmoRot_model = self.world.loader.loadModel(model_path) + gizmo_model = self.world.loader.loadModel(arrow_filename) + gizmoRot_model = self.world.loader.loadModel(model_filename) else: - gizmo_model = self.world.loader.loadModel(model_path) + gizmo_model = self.world.loader.loadModel(model_filename) except Exception as e: print(f"加载模型失败: {e}") return diff --git a/core/world.py b/core/world.py index 99638532..9edd2069 100644 --- a/core/world.py +++ b/core/world.py @@ -84,6 +84,20 @@ class CoreWorld(Meta3DWorld): model_path.appendDirectory(core_filename) print(f"✓ 添加core目录到模型搜索路径: {core_dir}") + # 添加RenderPipeline目录到搜索路径 + rp_dir = os.path.join(project_root, "RenderPipelineFile") + rp_filename = Filename.from_os_specific(rp_dir) + if not model_path.findFile(rp_filename): + model_path.appendDirectory(rp_filename) + print(f"✓ 添加RenderPipeline目录到模型搜索路径: {rp_dir}") + + # 添加RenderPipeline data目录到搜索路径 + rp_data_dir = os.path.join(rp_dir, "data") + rp_data_filename = Filename.from_os_specific(rp_data_dir) + if not model_path.findFile(rp_data_filename): + model_path.appendDirectory(rp_data_filename) + print(f"✓ 添加RenderPipeline data目录到模型搜索路径: {rp_data_dir}") + # 同时添加各个子目录到搜索路径 subdirs = ['models', 'textures', 'animations', 'icons', 'materials'] for subdir in subdirs: diff --git a/ui/property_panel.py b/ui/property_panel.py index 3411306f..bbfb2c28 100644 --- a/ui/property_panel.py +++ b/ui/property_panel.py @@ -9146,9 +9146,21 @@ class PropertyPanelManager: # 其他格式使用标准 Actor 加载 try: import gltf - print(f"[GLTF加载] 尝试加载: {filepath}") + from panda3d.core import Filename + + # 将Panda3D路径转换为操作系统特定路径 + panda_filename = Filename(filepath) + os_specific_path = panda_filename.to_os_specific() + print(f"[路径转换] {filepath} -> {os_specific_path}") + + print(f"[GLTF加载] 尝试加载: {os_specific_path}") + + # 使用明确的设置确保动画被加载 + gltf_settings = gltf.GltfSettings(skip_animations=False) # test_actor=Actor(NodePath(gltf._loader.GltfLoader.load_file(filepath,None))) - test_actor = Actor(NodePath(gltf.load_model(filepath, None))) + model_root = gltf.load_model(os_specific_path, gltf_settings) + model_node = NodePath(model_root) + test_actor = Actor(model_node) anims = test_actor.getAnimNames() test_actor.reparentTo(self.world.render) self._actor_cache[origin_model] = test_actor