Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MeshModel 再設計 #156

Open
lriki opened this issue Jul 3, 2020 · 0 comments
Open

MeshModel 再設計 #156

lriki opened this issue Jul 3, 2020 · 0 comments

Comments

@lriki
Copy link
Collaborator

lriki commented Jul 3, 2020

Proposal

Instantiate

WorldObject を作るときは次のようにできるようにする。

auto model = MeshModel::load(u"model.gltf");
auto obj1 = StaticMesh::create(model);
auto obj2 = SkinnedMesh::create(model);

現行↓

auto model1 = StaticMeshModel::load(u"model.gltf");
auto model2 = SkinnedMeshModel::load(u"model.gltf");
auto obj1 = StaticMesh::create(model1);
auto obj2 = SkinnedMesh::create(model2);

動的データの操作

WorldObject(Component) からアクセスする。

auto obj2 = SkinnedMesh::create(model);

// フォーマルな方法
SkinnedMeshBone* bone = obj2->skinnedMeshComponent()->findBone(u"");
bone->setRotation(...);

// ユーティリティ
SkinnedMeshBone* bone = obj2->findBone(u"");
bone->setRotation(...);

SkinnedMeshBone は Transform の派生とし、Editor 上からアクセスできるようにする。 (Unity と同じ仕組み)

Motivation

データの分離

MeshModel(StaticMeshModel と SkinnedMeshModel) は静的なデータと動的なデータが統合されていて、リソースの共有が難しい。
これを分離したい。

静的なデータは次の通り。

  • Mesh(LOD)
    • VertexBuffer
    • IndexBuffer
    • Section
    • モーフィング用位置VertexBuffer
  • Material
  • Node構造
  • InitialTransform
  • Bone構造
  • IK情報

動的なデータは次の通り。

  • AnimationController
  • SkinningMatrices(Bone姿勢)
  • SkinningMatricesTexture(SkinningMatrices を GPU に渡すバッファ)
  • Morph ブレンド率

継承関係の廃止

SkinnedMeshModel は StaticMeshModel の派生クラスとなっているが、
例えば .gltf をインポートしただけではどちらのインスタンスを作るべきか判断できないことがある。
そのため MeshModel クラスに統合し、Bone の有無などはコンポーネント志向の考え方で持たせたい。

Note

Model:Instance の対応関係は次のようなイメージ

  • MeshModel(*) - MeshModelInstance(今のところ公開予定なし)
  • MeshBoneModel - SkinnedMeshBone(*)

*: ユーザープログラムに積極的に公開することになるクラス。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant