45 lines
4.0 KiB
Markdown
45 lines
4.0 KiB
Markdown
## 1. ViewportCamera
|
|
|
|
- [x] 1.1 Create `src/core/ViewportCamera.h` with class declaration: eye, focalPoint, up vector, fov, nearClip, farClip, aspectRatio; methods for orbit/pan/zoom, view matrix, projection matrix computation
|
|
- [x] 1.2 Implement `src/core/ViewportCamera.cpp`: `LookAt` view matrix, perspective projection matrix, orbit (spherical coords around focal point), pan (translate eye+focal in view plane), zoom (adjust distance to focal point proportionally)
|
|
- [x] 1.3 Add `FrameBoundingBox(bounding box)` method that positions the camera to view the entire scene
|
|
|
|
## 2. UsdSceneRenderer
|
|
|
|
- [x] 2.1 Create `src/core/UsdSceneRenderer.h` with class declaration: stage ref, OpenGL buffer handles, methods for `SetStage()`, `Rebuild()`, `Render()`, `Cleanup()`
|
|
- [x] 2.2 Implement `src/core/UsdSceneRenderer.cpp` — stage traversal: iterate prims, filter `UsdGeomMesh`, extract `points`, `faceVertexCounts`, `faceVertexIndices`, `normals`
|
|
- [x] 2.3 Implement geometry upload: create VAO/VBO per mesh, handle triangulation from `faceVertexCounts`, compute flat normals when authored normals are missing
|
|
- [x] 2.4 Implement material color extraction: read `UsdShadeMaterial` binding diffuse color, fall back to `primvars:displayColor`, fall back to default gray (0.7, 0.7, 0.7)
|
|
- [x] 2.5 Implement GLSL #version 130 shaders: vertex shader (MVP transform + normal transform), fragment shader (directional light + ambient + diffuse color)
|
|
- [x] 2.6 Implement `Render()` method: bind shader, set view/projection uniforms, iterate meshes and draw with their material colors
|
|
- [x] 2.7 Implement `Cleanup()` and `Rebuild()`: delete old OpenGL buffers, re-traverse stage, re-upload geometry
|
|
|
|
## 3. ViewportPanel (FBO + ImGui Integration)
|
|
|
|
- [x] 3.1 Create `src/ui/ViewportPanel.h` with class declaration: FBO/color/depth texture handles, `ViewportCamera`, `UsdSceneRenderer`, dimensions; methods for `SetStage()`, `Render()`, `HandleInput()`
|
|
- [x] 3.2 Implement FBO creation and resize logic: create color + depth attachments, detect dimension changes from `ImGui::GetContentRegionAvail()`, resize FBO only when dimensions change
|
|
- [x] 3.3 Implement `Render()`: bind FBO, clear with background color, call `UsdSceneRenderer::Render()` with camera matrices, unbind FBO, display color texture via `ImGui::Image()`
|
|
- [x] 3.4 Implement mouse input routing: detect viewport hover via `ImGui::IsWindowHovered()`, capture left-drag (orbit), middle-drag/shift+left-drag (pan), scroll (zoom), forward deltas to `ViewportCamera`
|
|
|
|
## 4. Viewport Overlay (Grid + Gizmo + Context Menu)
|
|
|
|
- [x] 4.1 Implement ground grid rendering: draw lines on Y=0 plane at regular intervals using GL_LINES in the scene renderer pass
|
|
- [x] 4.2 Implement axis gizmo rendering: draw RGB (XYZ) lines in the lower-left viewport corner using an orthographic overlay pass independent of the scene camera
|
|
- [x] 4.3 Implement background color configuration: store background color, use it for `glClear` in the FBO render pass
|
|
- [x] 4.4 Implement viewport right-click context menu with "Show Grid" toggle and "Background" color preset submenu
|
|
|
|
## 5. Application Integration
|
|
|
|
- [x] 5.1 Add `ViewportPanel` member to `Application`, initialize in `Application::Initialize()`, wire to `UsdStageManager` via `SetStage()`
|
|
- [x] 5.2 Replace the placeholder Viewport `ImGui::Begin/End` block in `Application::RenderUI()` with `ViewportPanel::Render()`
|
|
- [x] 5.3 Call `ViewportCamera::FrameBoundingBox()` in `RefreshManagers()` when a new stage is loaded so the camera frames the scene
|
|
- [x] 5.4 Verify all existing panels (Scene Hierarchy, Layer Panel, Property Panel) still render correctly alongside the new ViewportPanel
|
|
|
|
## 6. Build and Test
|
|
|
|
- [x] 6.1 Run `cmake --preset default` and `cmake --build` to verify compilation with new source files
|
|
- [x] 6.2 Launch the application, open a USD file with mesh geometry, verify geometry renders in the Viewport panel
|
|
- [x] 6.3 Test orbit, pan, zoom interactions in the viewport
|
|
- [x] 6.4 Test grid toggle and background color from context menu
|
|
- [x] 6.5 Test FBO resize by docking/undocking/resizing the Viewport panel
|