|
| 1 | +--- |
| 2 | +title: IKDemoEditor |
| 3 | +date: 2025-12-08 |
| 4 | +category: cpp |
| 5 | +description: IKDemoEditor |
| 6 | +tags: [cpp, editor] |
| 7 | +recommended: true |
| 8 | +thumbnail: assets/img/ogp.png |
| 9 | +--- |
| 10 | + |
| 11 | +こんにちは!パン君です。 |
| 12 | + |
| 13 | +```mermaid |
| 14 | +%% パッケージ図(モジュール概観) |
| 15 | +graph TD |
| 16 | + subgraph FND |
| 17 | + Instance |
| 18 | + Logger |
| 19 | + Assert |
| 20 | + Util |
| 21 | + Flag |
| 22 | + end |
| 23 | +
|
| 24 | + subgraph Core |
| 25 | + Main |
| 26 | + SceneSystem |
| 27 | + ActorManager |
| 28 | + end |
| 29 | +
|
| 30 | + subgraph FrameWork |
| 31 | + Actor |
| 32 | + Component |
| 33 | + Transform |
| 34 | + ModelComponent |
| 35 | + VelocityMap |
| 36 | + IKComponents |
| 37 | + end |
| 38 | +
|
| 39 | + subgraph Graphics |
| 40 | + IDevice |
| 41 | + IContext |
| 42 | + ISwapChain |
| 43 | + IMesh |
| 44 | + IModelResource |
| 45 | + IShader |
| 46 | + RenderManager |
| 47 | + end |
| 48 | +
|
| 49 | + subgraph Math |
| 50 | + Vector |
| 51 | + Matrix |
| 52 | + Quaternion |
| 53 | + BreadMath |
| 54 | + end |
| 55 | +
|
| 56 | + subgraph IK |
| 57 | + ChainFABRIKManager |
| 58 | + FARBIKManager |
| 59 | + HumanFARBIKManager |
| 60 | + CCDIK |
| 61 | + end |
| 62 | +
|
| 63 | + FND --> Core |
| 64 | + Core --> FrameWork |
| 65 | + FrameWork --> Graphics |
| 66 | + Graphics --> Math |
| 67 | + IK --> FrameWork |
| 68 | + IK --> Graphics |
| 69 | + FrameWork --> FND |
| 70 | +``` |
| 71 | + |
| 72 | +```mermaid |
| 73 | +classDiagram |
| 74 | +%% 主要クラスと関係(拡張版) |
| 75 | +class Instance<T> { |
| 76 | + <<template>> |
| 77 | + + static T instance |
| 78 | +} |
| 79 | +class SharedInstance<T> { |
| 80 | + <<template>> |
| 81 | + + static shared_ptr<T> instance |
| 82 | + + static T* makeInstancePtr(...) |
| 83 | +} |
| 84 | +class MapInstance<T> { |
| 85 | + <<template>> |
| 86 | + + static map<string, T> instance |
| 87 | + + static T& MakeInstance(string, ...) |
| 88 | +} |
| 89 | +
|
| 90 | +class Logger { |
| 91 | + + static void SetWriter(ILogWriter*) |
| 92 | + + static void SetLevel(LogLevel) |
| 93 | + + static void Print(u32 type, LogLevel level, ...) |
| 94 | +} |
| 95 | +
|
| 96 | +class Actor { |
| 97 | + - vector<shared_ptr<Component>> components |
| 98 | + - vector<shared_ptr<Actor>> children |
| 99 | + + static shared_ptr<Actor> Create() |
| 100 | + + AddComponent<T>(...) |
| 101 | + + GetComponent<T>() |
| 102 | + + GetAllComponent() |
| 103 | + + AddChildActor<T>(...) |
| 104 | +} |
| 105 | +
|
| 106 | +class Component { |
| 107 | + - weak_ptr<Actor> owner |
| 108 | + - string ID |
| 109 | + + Initialize() |
| 110 | + + PreUpdate() |
| 111 | + + Update() |
| 112 | + + NextUpdate() |
| 113 | + + Draw() |
| 114 | + + GUI() |
| 115 | +} |
| 116 | +
|
| 117 | +class Transform { |
| 118 | + - Vector3 translate |
| 119 | + - Quaternion rotate |
| 120 | + - Vector3 scale |
| 121 | + + SetTranslate(Vector3) |
| 122 | + + SetRotate(Quaternion) |
| 123 | + + SetScale(Vector3) |
| 124 | + + const Matrix& GetLocalTransform() |
| 125 | + + const Matrix& GetWorldTransform() |
| 126 | + + GUI() |
| 127 | +} |
| 128 | +
|
| 129 | +class ActorManager { |
| 130 | + - vector<shared_ptr<Actor>> actors |
| 131 | + + Initialize() |
| 132 | + + Update() |
| 133 | + + Draw() |
| 134 | + + AddActors(shared_ptr<Actor>) |
| 135 | + + RemoveActor(shared_ptr<Actor>) |
| 136 | + + GetActorFromID(string) |
| 137 | +} |
| 138 | +
|
| 139 | +class IDevice { |
| 140 | + <<interface>> |
| 141 | + + static unique_ptr<IDevice> Create() |
| 142 | + + Initialize() |
| 143 | + + Finalize() |
| 144 | +} |
| 145 | +
|
| 146 | +class IContext { |
| 147 | + <<interface>> |
| 148 | + + static unique_ptr<IContext> Create() |
| 149 | + + Initialize(IDevice*) |
| 150 | + + Draw(...) |
| 151 | + + Begin() |
| 152 | + + End() |
| 153 | +} |
| 154 | +
|
| 155 | +class IMesh { |
| 156 | + <<interface>> |
| 157 | + + static unique_ptr<IMesh> Create() |
| 158 | + + Initialize(IDevice*, MeshDesc) |
| 159 | + + Draw(IDevice*, ...) |
| 160 | + + ComputeBounds() |
| 161 | +} |
| 162 | +
|
| 163 | +class RenderManager { |
| 164 | + - map<string, shared_ptr<IShader>> shaders |
| 165 | + + Initialize() |
| 166 | + + Render() |
| 167 | + + RegisterModelRenderShader(string, IShader) |
| 168 | +} |
| 169 | +
|
| 170 | +class Model { |
| 171 | + - vector<Node> nodes |
| 172 | + - vector<MeshNode> meshNodes |
| 173 | + + Load(IGraphicsDevice*, const char* filename) |
| 174 | + + Update() |
| 175 | +} |
| 176 | +
|
| 177 | +class FARBIKManager { |
| 178 | + - vector<shared_ptr<IKSetUp>> registedIK |
| 179 | + + RegisterFABRIK(vector<IJoint>*, shared_ptr<Transform>, Vector3* target) |
| 180 | + + UnRegisterFABRIK(...) |
| 181 | + + Update() |
| 182 | + + GUI() |
| 183 | +} |
| 184 | +
|
| 185 | +class CCDIK { |
| 186 | + + FootCCDIK(...) |
| 187 | + + Update() |
| 188 | + + GUI() |
| 189 | +} |
| 190 | +
|
| 191 | +%% 継承 / 関連 |
| 192 | +Component <|-- Transform |
| 193 | +Component <|-- Model |
| 194 | +Component <|-- VelocityMap |
| 195 | +Actor "1" o-- "many" Component |
| 196 | +Actor "1" o-- "many" Actor : children |
| 197 | +ActorManager "1" o-- "many" Actor |
| 198 | +Transform --> Matrix |
| 199 | +Model --> IMesh |
| 200 | +RenderManager --> IShader |
| 201 | +FARBIKManager ..> CCDIK : may use |
| 202 | +SphereModelComponent ..> FARBIKManager : registers |
| 203 | +``` |
| 204 | + |
| 205 | +```mermaid |
| 206 | +sequenceDiagram |
| 207 | +%% シーケンス:フレーム内の IK 実行フロー(代表) |
| 208 | +participant Main |
| 209 | +participant SceneSystem |
| 210 | +participant SceneGame |
| 211 | +participant ActorManager |
| 212 | +participant Actor |
| 213 | +participant SphereModelComponent |
| 214 | +participant FARBIKManager |
| 215 | +participant IMesh |
| 216 | +
|
| 217 | +Main->>SceneSystem: Update() |
| 218 | +SceneSystem->>SceneGame: Update() |
| 219 | +SceneGame->>ActorManager: Update() |
| 220 | +ActorManager->>Actor: Update() |
| 221 | +Actor->>SphereModelComponent: NextUpdate() |
| 222 | +SphereModelComponent->>FARBIKManager: RegisterFABRIK/Update() |
| 223 | +FARBIKManager->>FARBIKManager: FABRIK (Forward/Backward solve) |
| 224 | +FARBIKManager->>SphereModelComponent: Apply transforms |
| 225 | +SphereModelComponent->>IMesh: ComputeSkinnedVertices/Update |
| 226 | +IMesh-->>SphereModelComponent: updated mesh data |
| 227 | +SphereModelComponent-->>Actor: done |
| 228 | +Actor-->>ActorManager: done |
| 229 | +ActorManager-->>SceneGame: done |
| 230 | +SceneGame-->>SceneSystem: done |
| 231 | +SceneSystem-->>Main: done |
| 232 | +``` |
0 commit comments