ADD: glTF instance rotation, animation

This commit is contained in:
2025-11-29 23:25:16 +09:00
parent 217467a1fe
commit d09a79d47c
7 changed files with 310 additions and 91 deletions

View File

@@ -81,7 +81,33 @@ Docs: `docs/Scene.md`
- `bool setGLTFInstanceAnimationLoop(const std::string &instanceName, bool loop);`
- Notes:
- All functions return `bool` indicating whether the named scene/instance exists.
- `SceneManager::update_scene()` advances active animations each frame using engine delta time.
- Animation state is **independent per scene and per instance**:
- Each named scene has its own `AnimationState`.
- Each glTF instance has its own `AnimationState`, even when sharing the same `LoadedGLTF`.
- An index `< 0` (e.g. `-1`) disables animation for that scene/instance (pose is frozen at the last evaluated state).
- `SceneManager::update_scene()` advances each active animation state every frame using engine delta time.
### PerInstance Node / Joint Control (NonSkinned)
For rigid models and simple “joints” (e.g. flaps, doors, turrets), you can apply localspace pose offsets to individual glTF nodes per instance:
- `bool setGLTFInstanceNodeOffset(const std::string &instanceName, const std::string &nodeName, const glm::mat4 &offset);`
- `bool clearGLTFInstanceNodeOffset(const std::string &instanceName, const std::string &nodeName);`
- `void clearGLTFInstanceNodeOffsets(const std::string &instanceName);`
Typical usage:
- Use glTF animation for the base motion (e.g. gear deployment).
- Layer gamedriven offsets on top for perinstance control:
```cpp
// Rotate a control surface on one aircraft instance
glm::mat4 offset =
glm::rotate(glm::mat4(1.f),
glm::radians(aileronDegrees),
glm::vec3(1.f, 0.f, 0.f));
sceneMgr->setGLTFInstanceNodeOffset("plane01", "LeftAileron", offset);
```
### Point Lights
@@ -163,4 +189,3 @@ These are primarily debug/editor features but can be kept in a game build to pro
- Pointlight editor UI built on `SceneManager` light APIs.
- Object gizmo (ImGuizmo):
- Uses last pick / hover pick as the current target and manipulates transforms via `setMeshInstanceTransform` / `setGLTFInstanceTransform`.