vr修改
This commit is contained in:
parent
3b1b547ed8
commit
73e6e64a2e
@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"render_mode": "render_pipeline",
|
"render_mode": "render_pipeline",
|
||||||
"resolution_scale": 0.75,
|
"resolution_scale": 0.75,
|
||||||
"pipeline_resolution_scale": 0.75,
|
"pipeline_resolution_scale": 0.75,
|
||||||
"quality_preset": "quality",
|
"quality_preset": "quality",
|
||||||
"pipeline_vr_config": {
|
"pipeline_vr_config": {
|
||||||
"enable_shadows": true,
|
"enable_shadows": true,
|
||||||
"enable_ao": true,
|
"enable_ao": true,
|
||||||
"enable_bloom": false,
|
"enable_bloom": false,
|
||||||
"enable_motion_blur": false,
|
"enable_motion_blur": false,
|
||||||
"enable_ssr": false,
|
"enable_ssr": false,
|
||||||
"shadow_quality": "medium",
|
"shadow_quality": "medium",
|
||||||
"ao_quality": "low"
|
"ao_quality": "low"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,18 +1,15 @@
|
|||||||
{
|
{
|
||||||
"render_mode": "render_pipeline",
|
"render_mode": "render_pipeline",
|
||||||
"resolution_scale": 0.75,
|
"resolution_scale": 0.75,
|
||||||
"pipeline_resolution_scale": 0.75,
|
"pipeline_resolution_scale": 0.75,
|
||||||
"quality_preset": "quality",
|
"quality_preset": "quality",
|
||||||
"pipeline_vr_config": {
|
"pipeline_vr_config": {
|
||||||
"enable_shadows": true,
|
"enable_shadows": true,
|
||||||
"enable_ao": true,
|
"enable_ao": true,
|
||||||
"enable_bloom": false,
|
"enable_bloom": false,
|
||||||
"enable_motion_blur": false,
|
"enable_motion_blur": false,
|
||||||
"enable_ssr": false,
|
"enable_ssr": false,
|
||||||
"shadow_quality": "medium",
|
"shadow_quality": "medium",
|
||||||
"ao_quality": "low"
|
"ao_quality": "low"
|
||||||
},
|
}
|
||||||
"anti_aliasing": "4x",
|
|
||||||
"refresh_rate": "90Hz",
|
|
||||||
"async_reprojection": true
|
|
||||||
}
|
}
|
||||||
10
imgui.ini
10
imgui.ini
@ -144,6 +144,16 @@ Pos=625,308
|
|||||||
Size=600,400
|
Size=600,400
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][VR状态]
|
||||||
|
Pos=162,152
|
||||||
|
Size=138,296
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][VR设置]
|
||||||
|
Pos=474,130
|
||||||
|
Size=120,384
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,20 Size=1850,996 Split=X
|
DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,20 Size=1850,996 Split=X
|
||||||
DockNode ID=0x00000003 Parent=0x08BD597D SizeRef=1521,996 Split=Y
|
DockNode ID=0x00000003 Parent=0x08BD597D SizeRef=1521,996 Split=Y
|
||||||
|
|||||||
467
main.py
467
main.py
@ -273,6 +273,11 @@ class MyWorld(CoreWorld):
|
|||||||
self.showToolbar = True
|
self.showToolbar = True
|
||||||
self.showResourceManager = True
|
self.showResourceManager = True
|
||||||
|
|
||||||
|
# VR窗口控制
|
||||||
|
self.showVRSettingsWindow = False
|
||||||
|
self.showVRStatusWindow = False
|
||||||
|
self.showVRDebugWindow = False
|
||||||
|
|
||||||
# 脚本系统状态变量
|
# 脚本系统状态变量
|
||||||
self.hotReloadEnabled = True
|
self.hotReloadEnabled = True
|
||||||
self._new_script_name = "new_script"
|
self._new_script_name = "new_script"
|
||||||
@ -727,6 +732,11 @@ class MyWorld(CoreWorld):
|
|||||||
if self.showDemoWindow:
|
if self.showDemoWindow:
|
||||||
imgui.show_demo_window()
|
imgui.show_demo_window()
|
||||||
|
|
||||||
|
# 绘制VR窗口
|
||||||
|
self._draw_vr_settings_window()
|
||||||
|
self._draw_vr_status_window()
|
||||||
|
self._draw_vr_debug_window()
|
||||||
|
|
||||||
# 绘制对话框
|
# 绘制对话框
|
||||||
self._draw_new_project_dialog()
|
self._draw_new_project_dialog()
|
||||||
self._draw_open_project_dialog()
|
self._draw_open_project_dialog()
|
||||||
@ -4239,6 +4249,431 @@ class MyWorld(CoreWorld):
|
|||||||
self._color_picker_current_color = initial_color
|
self._color_picker_current_color = initial_color
|
||||||
self._color_picker_callback = callback
|
self._color_picker_callback = callback
|
||||||
|
|
||||||
|
def _draw_vr_settings_window(self):
|
||||||
|
"""绘制VR设置窗口"""
|
||||||
|
if not self.showVRSettingsWindow:
|
||||||
|
return
|
||||||
|
|
||||||
|
flags = imgui.WindowFlags_.no_collapse
|
||||||
|
with imgui_ctx.begin("VR设置", self.showVRSettingsWindow, flags) as (expanded, opened):
|
||||||
|
self.showVRSettingsWindow = opened
|
||||||
|
|
||||||
|
if expanded:
|
||||||
|
# 加载VR配置
|
||||||
|
if not hasattr(self, '_vr_config'):
|
||||||
|
self._load_vr_config()
|
||||||
|
|
||||||
|
config = self._vr_config
|
||||||
|
|
||||||
|
# 渲染模式选择
|
||||||
|
imgui.text("渲染模式:")
|
||||||
|
render_modes = ["normal", "render_pipeline"]
|
||||||
|
current_render_mode = 0 if config.get('render_mode') == 'normal' else 1
|
||||||
|
|
||||||
|
changed, new_render_mode = imgui.combo(
|
||||||
|
"##render_mode", current_render_mode, ["普通渲染", "RenderPipeline高级渲染"]
|
||||||
|
)
|
||||||
|
if changed:
|
||||||
|
config['render_mode'] = render_modes[new_render_mode]
|
||||||
|
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
# 质量预设选择
|
||||||
|
imgui.text("质量预设:")
|
||||||
|
quality_presets = ["performance", "balanced", "quality"]
|
||||||
|
quality_map = {"performance": 0, "balanced": 1, "quality": 2}
|
||||||
|
current_quality = quality_map.get(config.get('quality_preset', 'quality'), 2)
|
||||||
|
|
||||||
|
changed, new_quality = imgui.combo(
|
||||||
|
"##quality_preset", current_quality, ["性能", "平衡", "质量"]
|
||||||
|
)
|
||||||
|
if changed:
|
||||||
|
config['quality_preset'] = quality_presets[new_quality]
|
||||||
|
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
# 分辨率缩放
|
||||||
|
imgui.text("分辨率缩放:")
|
||||||
|
resolution_scale = config.get('resolution_scale', 0.75)
|
||||||
|
changed, new_scale = imgui.slider_float(
|
||||||
|
"##resolution_scale", resolution_scale, 0.5, 1.0, "%.2f"
|
||||||
|
)
|
||||||
|
if changed:
|
||||||
|
config['resolution_scale'] = new_scale
|
||||||
|
config['pipeline_resolution_scale'] = new_scale
|
||||||
|
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
# 渲染管线设置
|
||||||
|
imgui.text("渲染管线设置:")
|
||||||
|
|
||||||
|
if 'pipeline_vr_config' not in config:
|
||||||
|
config['pipeline_vr_config'] = {}
|
||||||
|
|
||||||
|
pipeline_config = config['pipeline_vr_config']
|
||||||
|
|
||||||
|
# 阴影设置
|
||||||
|
enable_shadows = pipeline_config.get('enable_shadows', True)
|
||||||
|
changed, new_shadows = imgui.checkbox("启用阴影", enable_shadows)
|
||||||
|
if changed:
|
||||||
|
pipeline_config['enable_shadows'] = new_shadows
|
||||||
|
|
||||||
|
# AO设置
|
||||||
|
enable_ao = pipeline_config.get('enable_ao', True)
|
||||||
|
changed, new_ao = imgui.checkbox("启用环境光遮蔽", enable_ao)
|
||||||
|
if changed:
|
||||||
|
pipeline_config['enable_ao'] = new_ao
|
||||||
|
|
||||||
|
# Bloom设置
|
||||||
|
enable_bloom = pipeline_config.get('enable_bloom', False)
|
||||||
|
changed, new_bloom = imgui.checkbox("启用Bloom效果", enable_bloom)
|
||||||
|
if changed:
|
||||||
|
pipeline_config['enable_bloom'] = new_bloom
|
||||||
|
|
||||||
|
# Motion Blur设置
|
||||||
|
enable_motion_blur = pipeline_config.get('enable_motion_blur', False)
|
||||||
|
changed, new_motion_blur = imgui.checkbox("启用动态模糊", enable_motion_blur)
|
||||||
|
if changed:
|
||||||
|
pipeline_config['enable_motion_blur'] = new_motion_blur
|
||||||
|
|
||||||
|
# SSR设置
|
||||||
|
enable_ssr = pipeline_config.get('enable_ssr', False)
|
||||||
|
changed, new_ssr = imgui.checkbox("启用屏幕空间反射", enable_ssr)
|
||||||
|
if changed:
|
||||||
|
pipeline_config['enable_ssr'] = new_ssr
|
||||||
|
|
||||||
|
# 阴影质量
|
||||||
|
shadow_quality_options = ["low", "medium", "high", "ultra"]
|
||||||
|
shadow_quality_map = {"low": 0, "medium": 1, "high": 2, "ultra": 3}
|
||||||
|
current_shadow_quality = shadow_quality_map.get(pipeline_config.get('shadow_quality', 'medium'), 1)
|
||||||
|
|
||||||
|
changed, new_shadow_quality = imgui.combo(
|
||||||
|
"阴影质量", current_shadow_quality, ["低", "中", "高", "极高"]
|
||||||
|
)
|
||||||
|
if changed:
|
||||||
|
pipeline_config['shadow_quality'] = shadow_quality_options[new_shadow_quality]
|
||||||
|
|
||||||
|
# AO质量
|
||||||
|
ao_quality_options = ["low", "medium", "high"]
|
||||||
|
ao_quality_map = {"low": 0, "medium": 1, "high": 2}
|
||||||
|
current_ao_quality = ao_quality_map.get(pipeline_config.get('ao_quality', 'low'), 0)
|
||||||
|
|
||||||
|
changed, new_ao_quality = imgui.combo(
|
||||||
|
"AO质量", current_ao_quality, ["低", "中", "高"]
|
||||||
|
)
|
||||||
|
if changed:
|
||||||
|
pipeline_config['ao_quality'] = ao_quality_options[new_ao_quality]
|
||||||
|
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
# 应用和重置按钮
|
||||||
|
if imgui.button("应用设置"):
|
||||||
|
self._save_vr_config()
|
||||||
|
self._apply_vr_config()
|
||||||
|
self.add_info_message("VR设置已应用")
|
||||||
|
|
||||||
|
imgui.same_line()
|
||||||
|
if imgui.button("重置默认"):
|
||||||
|
self._reset_vr_config()
|
||||||
|
self.add_info_message("VR设置已重置")
|
||||||
|
|
||||||
|
def _load_vr_config(self):
|
||||||
|
"""加载VR配置"""
|
||||||
|
try:
|
||||||
|
import json
|
||||||
|
config_path = os.path.join(os.getcwd(), 'config', 'vr_settings.json')
|
||||||
|
if os.path.exists(config_path):
|
||||||
|
with open(config_path, 'r', encoding='utf-8') as f:
|
||||||
|
self._vr_config = json.load(f)
|
||||||
|
else:
|
||||||
|
# 默认配置
|
||||||
|
self._vr_config = {
|
||||||
|
"render_mode": "render_pipeline",
|
||||||
|
"resolution_scale": 0.75,
|
||||||
|
"pipeline_resolution_scale": 0.75,
|
||||||
|
"quality_preset": "quality",
|
||||||
|
"pipeline_vr_config": {
|
||||||
|
"enable_shadows": True,
|
||||||
|
"enable_ao": True,
|
||||||
|
"enable_bloom": False,
|
||||||
|
"enable_motion_blur": False,
|
||||||
|
"enable_ssr": False,
|
||||||
|
"shadow_quality": "medium",
|
||||||
|
"ao_quality": "low"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
except Exception as e:
|
||||||
|
print(f"加载VR配置失败: {e}")
|
||||||
|
self._vr_config = {}
|
||||||
|
|
||||||
|
def _save_vr_config(self):
|
||||||
|
"""保存VR配置"""
|
||||||
|
try:
|
||||||
|
import json
|
||||||
|
config_path = os.path.join(os.getcwd(), 'config', 'vr_settings.json')
|
||||||
|
os.makedirs(os.path.dirname(config_path), exist_ok=True)
|
||||||
|
with open(config_path, 'w', encoding='utf-8') as f:
|
||||||
|
json.dump(self._vr_config, f, indent=4, ensure_ascii=False)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"保存VR配置失败: {e}")
|
||||||
|
self.add_error_message("保存VR配置失败")
|
||||||
|
|
||||||
|
def _apply_vr_config(self):
|
||||||
|
"""应用VR配置"""
|
||||||
|
if not self.vr_manager:
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
# 应用VR配置到VR管理器
|
||||||
|
config = self._vr_config
|
||||||
|
|
||||||
|
# 如果VR已启用,可能需要重新配置
|
||||||
|
if self.vr_manager.vr_enabled:
|
||||||
|
# TODO: 根据配置重新配置VR
|
||||||
|
pass
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"应用VR配置失败: {e}")
|
||||||
|
self.add_error_message("应用VR配置失败")
|
||||||
|
|
||||||
|
def _reset_vr_config(self):
|
||||||
|
"""重置VR配置到默认值"""
|
||||||
|
self._vr_config = {
|
||||||
|
"render_mode": "render_pipeline",
|
||||||
|
"resolution_scale": 0.75,
|
||||||
|
"pipeline_resolution_scale": 0.75,
|
||||||
|
"quality_preset": "quality",
|
||||||
|
"pipeline_vr_config": {
|
||||||
|
"enable_shadows": True,
|
||||||
|
"enable_ao": True,
|
||||||
|
"enable_bloom": False,
|
||||||
|
"enable_motion_blur": False,
|
||||||
|
"enable_ssr": False,
|
||||||
|
"shadow_quality": "medium",
|
||||||
|
"ao_quality": "low"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def _draw_vr_status_window(self):
|
||||||
|
"""绘制VR状态窗口"""
|
||||||
|
if not self.showVRStatusWindow:
|
||||||
|
return
|
||||||
|
|
||||||
|
flags = imgui.WindowFlags_.no_collapse | imgui.WindowFlags_.always_auto_resize
|
||||||
|
with imgui_ctx.begin("VR状态", self.showVRStatusWindow, flags) as (expanded, opened):
|
||||||
|
self.showVRStatusWindow = opened
|
||||||
|
|
||||||
|
if expanded and self.vr_manager:
|
||||||
|
# 控制更新频率,避免每帧都获取VR状态
|
||||||
|
current_time = imgui.get_io().delta_time
|
||||||
|
if not hasattr(self, '_vr_status_update_timer'):
|
||||||
|
self._vr_status_update_timer = 0.0
|
||||||
|
self._cached_vr_status = {}
|
||||||
|
|
||||||
|
self._vr_status_update_timer += current_time
|
||||||
|
|
||||||
|
# 每2秒更新一次VR状态
|
||||||
|
if self._vr_status_update_timer >= 2.0:
|
||||||
|
self._vr_status_update_timer = 0.0
|
||||||
|
try:
|
||||||
|
self._cached_vr_status = self.vr_manager.get_vr_status()
|
||||||
|
except Exception as e:
|
||||||
|
print(f"获取VR状态失败: {e}")
|
||||||
|
self._cached_vr_status = {}
|
||||||
|
|
||||||
|
vr_status = self._cached_vr_status
|
||||||
|
|
||||||
|
# 基本状态
|
||||||
|
imgui.text("基本状态:")
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
available = vr_status.get('available', False)
|
||||||
|
imgui.text(f"VR系统可用: {'是' if available else '否'}")
|
||||||
|
|
||||||
|
initialized = vr_status.get('initialized', False)
|
||||||
|
imgui.text(f"VR已初始化: {'是' if initialized else '否'}")
|
||||||
|
|
||||||
|
enabled = vr_status.get('enabled', False)
|
||||||
|
imgui.text(f"VR已启用: {'是' if enabled else '否'}")
|
||||||
|
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
# 渲染信息
|
||||||
|
imgui.text("渲染信息:")
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
eye_resolution = vr_status.get('eye_resolution', (0, 0))
|
||||||
|
imgui.text(f"眼睛分辨率: {eye_resolution[0]} x {eye_resolution[1]}")
|
||||||
|
|
||||||
|
device_count = vr_status.get('device_count', 0)
|
||||||
|
imgui.text(f"连接的设备数量: {device_count}")
|
||||||
|
|
||||||
|
vr_fps = vr_status.get('vr_fps', 0)
|
||||||
|
imgui.text(f"VR帧率: {vr_fps:.1f} FPS")
|
||||||
|
|
||||||
|
frame_count = vr_status.get('frame_count', 0)
|
||||||
|
imgui.text(f"总帧数: {frame_count}")
|
||||||
|
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
# 错误统计
|
||||||
|
imgui.text("错误统计:")
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
submit_failures = vr_status.get('submit_failures', 0)
|
||||||
|
imgui.text(f"提交失败次数: {submit_failures}")
|
||||||
|
|
||||||
|
pose_failures = vr_status.get('pose_failures', 0)
|
||||||
|
imgui.text(f"姿态失败次数: {pose_failures}")
|
||||||
|
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
# 刷新按钮和更新时间显示
|
||||||
|
if imgui.button("立即刷新"):
|
||||||
|
self._vr_status_update_timer = 0.5 # 强制更新
|
||||||
|
try:
|
||||||
|
self._cached_vr_status = self.vr_manager.get_vr_status()
|
||||||
|
except Exception as e:
|
||||||
|
print(f"获取VR状态失败: {e}")
|
||||||
|
|
||||||
|
imgui.same_line()
|
||||||
|
imgui.text(f"(更新间隔: 2秒)")
|
||||||
|
|
||||||
|
def _draw_vr_debug_window(self):
|
||||||
|
"""绘制VR调试窗口"""
|
||||||
|
if not self.showVRDebugWindow:
|
||||||
|
return
|
||||||
|
|
||||||
|
flags = imgui.WindowFlags_.no_collapse
|
||||||
|
with imgui_ctx.begin("VR调试", self.showVRDebugWindow, flags) as (expanded, opened):
|
||||||
|
self.showVRDebugWindow = opened
|
||||||
|
|
||||||
|
if expanded:
|
||||||
|
# 调试选项
|
||||||
|
imgui.text("调试选项:")
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
changed, self.vr_debug_enabled = imgui.checkbox("启用调试输出", self.vr_debug_enabled)
|
||||||
|
if changed and self.vr_manager:
|
||||||
|
if self.vr_debug_enabled:
|
||||||
|
self.vr_manager.enable_debug_output()
|
||||||
|
else:
|
||||||
|
self.vr_manager.disable_debug_output()
|
||||||
|
|
||||||
|
changed, self.vr_performance_monitor = imgui.checkbox("启用性能监控", self.vr_performance_monitor)
|
||||||
|
if changed and self.vr_manager:
|
||||||
|
if self.vr_performance_monitor:
|
||||||
|
self.vr_manager.enable_performance_monitoring()
|
||||||
|
else:
|
||||||
|
self.vr_manager.disable_performance_monitoring()
|
||||||
|
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
# 输出模式
|
||||||
|
imgui.text("输出模式:")
|
||||||
|
if imgui.radio_button("简短模式", not self.vr_detailed_mode):
|
||||||
|
self.vr_detailed_mode = False
|
||||||
|
if imgui.radio_button("详细模式", self.vr_detailed_mode):
|
||||||
|
self.vr_detailed_mode = True
|
||||||
|
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
# 性能监控选项
|
||||||
|
imgui.text("性能监控:")
|
||||||
|
gpu_timing = False
|
||||||
|
changed, gpu_timing = imgui.checkbox("GPU时间监控", gpu_timing)
|
||||||
|
if changed and self.vr_manager:
|
||||||
|
if gpu_timing:
|
||||||
|
self.vr_manager.enable_gpu_timing_monitoring()
|
||||||
|
else:
|
||||||
|
self.vr_manager.disable_gpu_timing_monitoring()
|
||||||
|
|
||||||
|
pipeline_monitoring = False
|
||||||
|
changed, pipeline_monitoring = imgui.checkbox("管线监控", pipeline_monitoring)
|
||||||
|
if changed and self.vr_manager:
|
||||||
|
if pipeline_monitoring:
|
||||||
|
self.vr_manager.enable_pipeline_monitoring(True)
|
||||||
|
else:
|
||||||
|
self.vr_manager.enable_pipeline_monitoring(False)
|
||||||
|
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
# 姿态策略
|
||||||
|
imgui.text("姿态策略:")
|
||||||
|
pose_strategies = ["默认", "Running Start", "Low Latency"]
|
||||||
|
current_pose_strategy = 0
|
||||||
|
|
||||||
|
changed, new_strategy = imgui.combo(
|
||||||
|
"##pose_strategy", current_pose_strategy, pose_strategies
|
||||||
|
)
|
||||||
|
if changed and self.vr_manager:
|
||||||
|
# TODO: 应用姿态策略
|
||||||
|
if new_strategy == 0:
|
||||||
|
pass # 默认策略
|
||||||
|
elif new_strategy == 1:
|
||||||
|
self.vr_manager.set_prediction_time(11.0) # Running Start
|
||||||
|
elif new_strategy == 2:
|
||||||
|
self.vr_manager.set_prediction_time(5.0) # Low Latency
|
||||||
|
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
# 测试模式
|
||||||
|
imgui.text("测试模式:")
|
||||||
|
test_mode = False
|
||||||
|
changed, test_mode = imgui.checkbox("启用测试模式", test_mode)
|
||||||
|
if changed and self.vr_manager:
|
||||||
|
if test_mode:
|
||||||
|
self.vr_manager.enable_vr_test_mode()
|
||||||
|
else:
|
||||||
|
self.vr_manager.disable_vr_test_mode()
|
||||||
|
|
||||||
|
texture_test = False
|
||||||
|
changed, texture_test = imgui.checkbox("纹理提交测试", texture_test)
|
||||||
|
if changed and self.vr_manager:
|
||||||
|
# TODO: 应用纹理提交测试
|
||||||
|
pass
|
||||||
|
|
||||||
|
pose_wait_test = False
|
||||||
|
changed, pose_wait_test = imgui.checkbox("姿态等待测试", pose_wait_test)
|
||||||
|
if changed and self.vr_manager:
|
||||||
|
# TODO: 应用姿态等待测试
|
||||||
|
pass
|
||||||
|
|
||||||
|
step_by_step_test = False
|
||||||
|
changed, step_by_step_test = imgui.checkbox("分步骤测试", step_by_step_test)
|
||||||
|
if changed and self.vr_manager:
|
||||||
|
# TODO: 应用分步骤测试
|
||||||
|
pass
|
||||||
|
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
# 实时性能数据
|
||||||
|
if self.vr_manager and self.vr_manager.vr_enabled:
|
||||||
|
imgui.text("实时性能数据:")
|
||||||
|
imgui.separator()
|
||||||
|
|
||||||
|
# 使用状态窗口的缓存数据,避免重复获取
|
||||||
|
if hasattr(self, '_cached_vr_status') and self._cached_vr_status:
|
||||||
|
vr_status = self._cached_vr_status
|
||||||
|
else:
|
||||||
|
# 如果没有缓存数据,创建一个空字典
|
||||||
|
vr_status = {}
|
||||||
|
|
||||||
|
vr_fps = vr_status.get('vr_fps', 0)
|
||||||
|
imgui.text(f"VR帧率: {vr_fps:.1f} FPS")
|
||||||
|
|
||||||
|
frame_count = vr_status.get('frame_count', 0)
|
||||||
|
imgui.text(f"总帧数: {frame_count}")
|
||||||
|
|
||||||
|
submit_failures = vr_status.get('submit_failures', 0)
|
||||||
|
imgui.text(f"提交失败: {submit_failures}")
|
||||||
|
|
||||||
|
pose_failures = vr_status.get('pose_failures', 0)
|
||||||
|
imgui.text(f"姿态失败: {pose_failures}")
|
||||||
|
|
||||||
|
# 显示数据更新状态
|
||||||
|
imgui.text(f"(数据更新率: 0.5秒)")
|
||||||
|
|
||||||
def _draw_color_picker(self):
|
def _draw_color_picker(self):
|
||||||
"""绘制颜色选择器对话框"""
|
"""绘制颜色选择器对话框"""
|
||||||
if not self._color_picker_active:
|
if not self._color_picker_active:
|
||||||
@ -8071,10 +8506,10 @@ class MyWorld(CoreWorld):
|
|||||||
def _toggle_vr_mode(self):
|
def _toggle_vr_mode(self):
|
||||||
"""切换VR模式"""
|
"""切换VR模式"""
|
||||||
if self.vr_manager:
|
if self.vr_manager:
|
||||||
if self.vr_manager.is_enabled():
|
if self.vr_manager.vr_enabled:
|
||||||
self._exit_vr_mode()
|
self._exit_vr_mode()
|
||||||
else:
|
else:
|
||||||
self.vr_manager.enable()
|
self.vr_manager.enable_vr()
|
||||||
self.add_info_message("已进入VR模式")
|
self.add_info_message("已进入VR模式")
|
||||||
else:
|
else:
|
||||||
self.add_error_message("VR管理器未初始化")
|
self.add_error_message("VR管理器未初始化")
|
||||||
@ -8082,39 +8517,29 @@ class MyWorld(CoreWorld):
|
|||||||
def _exit_vr_mode(self):
|
def _exit_vr_mode(self):
|
||||||
"""退出VR模式"""
|
"""退出VR模式"""
|
||||||
if self.vr_manager:
|
if self.vr_manager:
|
||||||
self.vr_manager.disable()
|
self.vr_manager.disable_vr()
|
||||||
self.add_info_message("已退出VR模式")
|
self.add_info_message("已退出VR模式")
|
||||||
|
|
||||||
def _show_vr_status(self):
|
def _show_vr_status(self):
|
||||||
"""显示VR状态"""
|
"""显示VR状态窗口"""
|
||||||
if self.vr_manager:
|
if self.vr_manager:
|
||||||
status = "已启用" if self.vr_manager.is_enabled() else "未启用"
|
self.showVRStatusWindow = not self.showVRStatusWindow
|
||||||
self.add_info_message(f"VR状态: {status}")
|
|
||||||
|
|
||||||
# 显示设备信息
|
|
||||||
if self.vr_manager.is_enabled():
|
|
||||||
devices = self.vr_manager.get_connected_devices()
|
|
||||||
if devices:
|
|
||||||
self.add_info_message(f"连接的设备: {', '.join(devices)}")
|
|
||||||
else:
|
|
||||||
self.add_info_message("未检测到VR设备")
|
|
||||||
else:
|
else:
|
||||||
self.add_error_message("VR管理器未初始化")
|
self.add_error_message("VR管理器未初始化")
|
||||||
|
|
||||||
def _show_vr_settings(self):
|
def _show_vr_settings(self):
|
||||||
"""显示VR设置"""
|
"""显示VR设置窗口"""
|
||||||
if self.vr_manager:
|
if self.vr_manager:
|
||||||
self.add_info_message("VR设置对话框待实现")
|
self.showVRSettingsWindow = not self.showVRSettingsWindow
|
||||||
else:
|
else:
|
||||||
self.add_error_message("VR管理器未初始化")
|
self.add_error_message("VR管理器未初始化")
|
||||||
|
|
||||||
def _show_vr_performance_report(self):
|
def _show_vr_performance_report(self):
|
||||||
"""显示VR性能报告"""
|
"""显示VR调试窗口"""
|
||||||
if self.vr_manager and self.vr_manager.is_enabled():
|
if self.vr_manager:
|
||||||
report = self.vr_manager.get_performance_report()
|
self.showVRDebugWindow = not self.showVRDebugWindow
|
||||||
self.add_info_message(f"VR性能报告: {report}")
|
|
||||||
else:
|
else:
|
||||||
self.add_info_message("VR未启用或管理器未初始化")
|
self.add_error_message("VR管理器未初始化")
|
||||||
|
|
||||||
def _get_chinese_font(self):
|
def _get_chinese_font(self):
|
||||||
"""获取中文字体"""
|
"""获取中文字体"""
|
||||||
|
|||||||
6724
ui/main_window.py
Normal file
6724
ui/main_window.py
Normal file
File diff suppressed because it is too large
Load Diff
4319
ui/widgets.py
Normal file
4319
ui/widgets.py
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user