티스토리 뷰
Hazel / Scene and Entity - component system
아, 동영상 보면 좀더 쉬울듯,
Serialize에는 YAML 을 사용
Component 로 각 객체를 구성 이건 Ray랑 비슷한가
객체에 add 하는 형태로 보인다
Entity entity = { m_Registry.create(), this };
entity.AddComponent<TransformComponent>();
CameraCompoment, TransformComponent 등을 일반적인 구조
glm::mat4 GetTransform() const
{
glm::mat4 rotation = glm::toMat4(glm::quat(Rotation));
return glm::translate(glm::mat4(1.0f), Translation)
* rotation
* glm::scale(glm::mat4(1.0f), Scale);
}
scriptable component를 위한 거 같음
struct NativeScriptComponent
{
ScriptableEntity* Instance = nullptr;
ScriptableEntity*(*InstantiateScript)();
void (*DestroyScript)(NativeScriptComponent*);
template<typename T>
void Bind()
{
InstantiateScript = []() { return static_cast<ScriptableEntity*>(new T()); };
DestroyScript = [](NativeScriptComponent* nsc) { delete nsc->Instance; nsc->Instance = nullptr; };
}
};
Assimp
모델만 로드해서, 애니메이션 생각을 빠트림
pmx 로더 pull 리퀘도 봤는데 왜 생각못했지
https://github.com/google/filament/blob/main/third_party/libassimp/code/FBX/FBXAnimation.cpp
Filament
https://github.com/google/filament/blob/main/samples/gltf_instances.cpp
app.asset->getAnimator();
app.viewer->applyAnimation(now);
단순 적용은 아래와 같음
void Animator::updateBoneMatrices()
// 음 그냥 평의한 형태
for (const auto& skin : asset->mSkins) {
size_t njoints = skin.joints.size();
boneMatrices.resize(njoints);
for (const auto& entity : skin.targets) {
auto renderable = renderableManager->getInstance(entity);
if (!renderable) {
continue;
}
mat4f inverseGlobalTransform;
auto xformable = transformManager->getInstance(entity);
if (xformable) {
inverseGlobalTransform = inverse(transformManager->getWorldTransform(xformable));
Animation setting은 아래부분에서 수행하는듯 복잡하므로, 직접 찍어봐야 대강 알듯
TransformManager* transformManager = mImpl->transformManager;
RenderableManager* renderableManager = mImpl->renderableManager;
time = fmod(time, anim.duration);
for (const auto& channel : anim.channels) {
const Sampler* sampler = channel.sourceData;
if (sampler->times.size() < 2) {
continue;
}
TransformManager::Instance node = transformManager->getInstance(channel.targetEntity);
const TimeValues& times = sampler->times;
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크