修复windows无法播放动画问题

This commit is contained in:
Hector 2025-11-06 10:30:39 +08:00
parent a3711c57ea
commit 176995652b
4 changed files with 37 additions and 10 deletions

View File

@ -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)

View File

@ -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

View File

@ -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:

View File

@ -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