155 lines
4.8 KiB
Markdown
155 lines
4.8 KiB
Markdown
# CLAUDE.md
|
||
|
||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||
|
||
## 项目概述
|
||
|
||
这是一个基于Panda3D的3D渲染引擎和场景编辑器,集成了PyQt5界面和多种高级功能:
|
||
|
||
- 3D场景编辑器(模型导入、材质系统、碰撞检测)
|
||
- GUI元素管理(2D/3D GUI组件)
|
||
- 项目管理系统(场景保存/加载、项目打包)
|
||
- Cesium地图集成
|
||
- 渲染管线增强(RenderPipelineFile)
|
||
|
||
## 运行和构建命令
|
||
|
||
### 启动应用程序
|
||
```bash
|
||
python Start_Run.py [project_path]
|
||
```
|
||
或者直接:
|
||
```bash
|
||
python main.py
|
||
```
|
||
|
||
### 依赖安装
|
||
```bash
|
||
# 主要依赖
|
||
pip install -r requirements/requirements.txt
|
||
|
||
# Conda环境依赖
|
||
pip install -r requirements/conda-requirements.txt
|
||
```
|
||
|
||
### 工具脚本
|
||
```bash
|
||
# 安装FBX到GLTF转换工具
|
||
./install_fbx2gltf.sh
|
||
```
|
||
|
||
## 核心架构
|
||
|
||
### 主要模块结构
|
||
```
|
||
EG/
|
||
├── main.py # 应用程序入口点
|
||
├── Start_Run.py # 启动脚本(路径配置)
|
||
├── core/ # 核心功能模块
|
||
│ ├── world.py # 3D世界核心(继承Panda3DWorld)
|
||
│ ├── scene_manager.py # 场景和模型管理
|
||
│ ├── selection.py # 对象选择系统
|
||
│ ├── event_handler.py # 事件处理
|
||
│ ├── tool_manager.py # 工具系统
|
||
│ ├── vr_manager.py # VR管理器(待重构)
|
||
│ └── vr/ # VR模块(模块化重构后)
|
||
│ ├── rendering/ # 渲染子系统
|
||
│ ├── tracking/ # 跟踪子系统
|
||
│ ├── interaction/ # 交互子系统
|
||
│ ├── visualization/ # 可视化子系统
|
||
│ ├── performance/ # 性能优化子系统
|
||
│ ├── testing/ # 测试调试子系统
|
||
│ └── config/ # 配置子系统
|
||
├── gui/ # GUI元素管理
|
||
│ └── gui_manager.py # 2D/3D GUI组件
|
||
├── ui/ # 用户界面
|
||
│ ├── widgets.py # 自定义Qt组件
|
||
│ ├── property_panel.py # 属性面板
|
||
│ └── interface_manager.py # 界面管理
|
||
├── scene/ # 场景相关
|
||
│ └── scene_manager.py # 场景管理器
|
||
├── project/ # 项目管理
|
||
│ └── project_manager.py # 项目生命周期
|
||
├── RenderPipelineFile/ # 渲染管线扩展
|
||
└── QPanda3D/ # Panda3D Qt集成
|
||
```
|
||
|
||
### 核心设计模式
|
||
|
||
1. **模块化架构**: 每个功能模块独立,通过管理器类协调
|
||
2. **事件驱动**: EventHandler统一处理用户交互和系统事件
|
||
3. **组件系统**: SelectionSystem、ToolManager等可插拔组件
|
||
4. **MVC分离**: UI组件、核心逻辑和数据管理分离
|
||
|
||
### 主要依赖集成
|
||
|
||
- **Panda3D 1.10.15**: 3D渲染引擎
|
||
- **PyQt5**: GUI框架
|
||
- **QPanda3D**: Panda3D的Qt集成
|
||
- **RenderPipeline**: 高级渲染功能
|
||
|
||
## 开发指南
|
||
|
||
### 添加新功能模块
|
||
1. 在对应目录下创建新的Python文件
|
||
2. 继承相应的基类(如Panda3DWorld用于3D功能)
|
||
3. 在main.py中集成新模块
|
||
4. 更新界面管理器以添加UI控制
|
||
|
||
### VR模块开发
|
||
VR模块采用模块化架构,包含7个子系统:
|
||
|
||
1. **rendering/** - 渲染子系统
|
||
- `stages.py`: VR专用渲染stages(GBuffer、光照、环境光、最终合成)
|
||
|
||
2. **tracking/** - 跟踪子系统
|
||
- `controllers.py`: VR控制器类(LeftController, RightController)
|
||
|
||
3. **interaction/** - 交互子系统
|
||
- `actions.py`: OpenVR动作系统
|
||
- `joystick.py`: 摇杆输入和转向/传送
|
||
- `teleport.py`: 传送系统(抛物线轨迹)
|
||
- `grab.py`: 对象抓取和交互
|
||
|
||
4. **visualization/** - 可视化子系统
|
||
- `controllers.py`: 控制器3D模型和射线可视化
|
||
- `effects.py`: VR特效管理
|
||
|
||
5. **config/** - 配置子系统
|
||
- `vr_config.py`: VR基础配置
|
||
- `joystick_config.py`: 摇杆配置
|
||
- `shadow_stage.py`: 阴影stage配置
|
||
|
||
6. **performance/** - 性能优化子系统(预留)
|
||
7. **testing/** - 测试调试子系统(预留)
|
||
|
||
**使用示例**:
|
||
```python
|
||
from core.vr import VRManager # 主接口(向后兼容)
|
||
from core.vr.interaction.teleport import VRTeleportSystem # 子模块
|
||
```
|
||
|
||
详细信息请查看 `core/vr/README.md`
|
||
|
||
### 材质和渲染
|
||
- 材质系统集成在scene/scene_manager.py
|
||
- 支持PBR材质和自定义着色器
|
||
- RenderPipelineFile提供高级渲染特性
|
||
|
||
### GUI开发
|
||
- 使用PyQt5构建主界面
|
||
- 3D GUI元素通过gui/gui_manager.py管理
|
||
- 自定义组件在ui/widgets.py中定义
|
||
|
||
## 文件约定
|
||
|
||
- Python文件使用UTF-8编码
|
||
- 中文注释和文档字符串
|
||
- 模块顶部包含功能描述注释
|
||
- 类和方法使用描述性命名
|
||
|
||
## 注意事项
|
||
|
||
- 项目依赖多个大型库(Panda3D、PyQt5、RenderPipeline)
|
||
- Cesium集成需要WebEngine支持
|
||
- 某些功能可能需要特定的系统配置 |