Loading age @ 6f228a8c Compare 4d6a2ee0 to 6f228a8c Original line number Diff line number Diff line Subproject commit 4d6a2ee00c0b8b08e3ee57521ce5133523d8a07c Subproject commit 6f228a8c6368a6de39130a7cfed65d9072b8343d src/maker/include/maker/presenter.hpp +4 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,10 @@ protected: void initialize() override; void release() override; void on_content_changed(com::File* const sender) override; private: std::unordered_map<com::File*, std::function<void(const std::vector<uint8_t>&)>> m_gltf_callbacks{}; }; } Loading src/maker/src/presenter.cpp +190 −158 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ #include <utils/gltf_importer.hpp> #include <anim/animation_player.hpp> #include <anim/index.hpp> #include <lfs/index.hpp> namespace mak { Loading Loading @@ -162,12 +163,26 @@ void main() { auto lit_skinning_material = gfx::material_system()->insert_default_lit_skinning_material("lit_skinning_material", { "maker" }, vec3{ 0.0f, 0.75f, 1.f }); // --- BEGIN GLTF --- auto skeletons = anim::root()->push_back<com::Folder>("skeletons"); auto instances = anim::root()->push_back<com::Folder>("instances"); // auto skeletons = anim::root()->push_back<com::Folder>("skeletons"); // auto instances = anim::root()->push_back<com::Folder>("instances"); index().root()->push_back<utils::GltfLoader>("rigged_cube.gltf", "models/rigged_cube.gltf", [skeletons, instances, lit_skinning_material](const tinygltf::Model& model) { utils::import_gltf(model, instances, "gltf_box", lit_skinning_material, vec3{-10, 0, 0}, vec3{0, 0, 1.57}); auto load_resource = [this](const std::string& path) { com::ContextPath ctxPath{}; boost::split(ctxPath, path, boost::is_any_of("/")); lfs::ResourceHandle* const handle{ lfs::loader()->load(ctxPath) }; if (handle->state() == lfs::ResourceHandle::LOADED) on_content_changed(handle); else handle->register_on_content_changed(this); return handle; }; const static std::string my_model_path = "models/rigged_cube.gltf"; auto handle = load_resource(my_model_path); m_gltf_callbacks[handle] = [lit_skinning_material](const std::vector<uint8_t>& data) { utils::import_gltf(data, my_model_path, "gltf_box", lit_skinning_material, vec3{-10, 0, 0}, vec3{0, 0, 1.57}); auto* gltf_cube_folder = com::Folder::root()->locate<com::Folder>({"maker", "gltf_box"}); auto* my_frame2 = dynamic_cast<com::Frame*>(gltf_cube_folder->copy_back(gltf_cube_folder->find<com::Frame>("frame"), "frame2")); Loading @@ -181,7 +196,7 @@ void main() { auto test_anim = anim::animation_system()->insert_animation_with_player("test_anim"); test_anim->add_track( "left_pos", com::Folder::root()->locate<com::Frame>({ "anim", "instances", "gltf_box", "Armature", "Bone.Root", "Bone.L", "frame"}), anim::animation_system()->instances()->locate<com::Frame>({ "gltf_box", "Armature", "Bone.Root", "Bone.L", "frame"}), "set_origin", anim::Keyframes<vec3>{ {0, {0, 0, 0}, -2.f}, Loading Loading @@ -321,7 +336,7 @@ void main() { if (!gfx::object_system()->has_light(obj, dir_light)) gfx::object_system()->insert_light(obj, dir_light); if (!gfx::object_system()->has_light(obj, ambient_light)) gfx::object_system()->insert_light(obj, ambient_light); } }); }; // --- END GLTF --- Loading @@ -336,23 +351,27 @@ void main() { auto catwalk_material = gfx::material_system()->insert_material("gltf_catwalk_material", lit_skinning_shader, { "maker" }); catwalk_material->set_uniform("color", vec3{ 0.0f, 0.75f, 1.f }); index().root()->push_back<utils::GltfLoader>("walk.gltf", "models/walk.gltf", [instances, human_material](const tinygltf::Model& model) { utils::import_gltf(model, instances, "gltf_human", human_material, vec3{2, 4, 0}); const static std::string my_model_path2 = "models/walk.gltf"; handle = load_resource(my_model_path2); m_gltf_callbacks[handle] = [human_material](const std::vector<uint8_t>& data) { utils::import_gltf(data, my_model_path2, "gltf_human", human_material, vec3{2, 4, 0}); update_lights(); print_tree(com::Folder::root(), std::cout, 4); anim::animation_system()->animations()->locate<com::Folder>({"gltf_human__Armature|mixamo.com|Layer0.anim", "vec3_tracks"})->erase("mixamorig:Hips_translation.track"); }); }; // index().root()->push_back<utils::GltfLoader>("rigged_double_cube.gltf", "models/rigged_double_cube.gltf", [skeletons, instances, lit_skinning_material](const tinygltf::Model& model) { // utils::import_gltf(model, instances, "gltf_double_box", lit_skinning_material, vec3{5, 0, 0}, vec3{0, 0, 1.57}); // update_lights(); // }); index().root()->push_back<utils::GltfLoader>("dance.gltf", "models/dance.gltf", [instances, human_material](const tinygltf::Model& model) { utils::import_gltf(model, instances, "gltf_dance", nullptr, vec3{-5, 4, 0}); const static std::string dance_model_path = "models/dance.gltf"; handle = load_resource(dance_model_path); m_gltf_callbacks[handle] = [human_material](const std::vector<uint8_t>& data) { utils::import_gltf(data, dance_model_path, "gltf_dance", nullptr, vec3{-5, 4, 0}); update_lights(); }); }; // utils::import_gltf(instances, "models/catwalk.gltf", "gltf_catwalk", nullptr, vec3{8, 4, 0}); // utils::import_gltf(instances, "models/gunplay.gltf", "gltf_gunplay", nullptr); // utils::import_gltf(instances, "models/walk_and_gun.gltf", "gltf_walk_and_gun", walk_material, vec3{-2, 4, 0}/* , identity<quat>(), "gltf_human" */); Loading Loading @@ -1161,4 +1180,17 @@ void Presenter::next_round() // glFlush(); } void Presenter::on_content_changed(com::File* const sender) { if (m_gltf_callbacks.contains(sender)) { if (auto handle = dynamic_cast<lfs::ResourceHandle*>(sender)) { ASSUMPTION(handle->state() == lfs::ResourceHandle::LOADED); m_gltf_callbacks[sender](handle->data()); handle->unregister_on_content_changed(this); m_gltf_callbacks.erase(sender); } } } } Loading
age @ 6f228a8c Compare 4d6a2ee0 to 6f228a8c Original line number Diff line number Diff line Subproject commit 4d6a2ee00c0b8b08e3ee57521ce5133523d8a07c Subproject commit 6f228a8c6368a6de39130a7cfed65d9072b8343d
src/maker/include/maker/presenter.hpp +4 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,10 @@ protected: void initialize() override; void release() override; void on_content_changed(com::File* const sender) override; private: std::unordered_map<com::File*, std::function<void(const std::vector<uint8_t>&)>> m_gltf_callbacks{}; }; } Loading
src/maker/src/presenter.cpp +190 −158 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ #include <utils/gltf_importer.hpp> #include <anim/animation_player.hpp> #include <anim/index.hpp> #include <lfs/index.hpp> namespace mak { Loading Loading @@ -162,12 +163,26 @@ void main() { auto lit_skinning_material = gfx::material_system()->insert_default_lit_skinning_material("lit_skinning_material", { "maker" }, vec3{ 0.0f, 0.75f, 1.f }); // --- BEGIN GLTF --- auto skeletons = anim::root()->push_back<com::Folder>("skeletons"); auto instances = anim::root()->push_back<com::Folder>("instances"); // auto skeletons = anim::root()->push_back<com::Folder>("skeletons"); // auto instances = anim::root()->push_back<com::Folder>("instances"); index().root()->push_back<utils::GltfLoader>("rigged_cube.gltf", "models/rigged_cube.gltf", [skeletons, instances, lit_skinning_material](const tinygltf::Model& model) { utils::import_gltf(model, instances, "gltf_box", lit_skinning_material, vec3{-10, 0, 0}, vec3{0, 0, 1.57}); auto load_resource = [this](const std::string& path) { com::ContextPath ctxPath{}; boost::split(ctxPath, path, boost::is_any_of("/")); lfs::ResourceHandle* const handle{ lfs::loader()->load(ctxPath) }; if (handle->state() == lfs::ResourceHandle::LOADED) on_content_changed(handle); else handle->register_on_content_changed(this); return handle; }; const static std::string my_model_path = "models/rigged_cube.gltf"; auto handle = load_resource(my_model_path); m_gltf_callbacks[handle] = [lit_skinning_material](const std::vector<uint8_t>& data) { utils::import_gltf(data, my_model_path, "gltf_box", lit_skinning_material, vec3{-10, 0, 0}, vec3{0, 0, 1.57}); auto* gltf_cube_folder = com::Folder::root()->locate<com::Folder>({"maker", "gltf_box"}); auto* my_frame2 = dynamic_cast<com::Frame*>(gltf_cube_folder->copy_back(gltf_cube_folder->find<com::Frame>("frame"), "frame2")); Loading @@ -181,7 +196,7 @@ void main() { auto test_anim = anim::animation_system()->insert_animation_with_player("test_anim"); test_anim->add_track( "left_pos", com::Folder::root()->locate<com::Frame>({ "anim", "instances", "gltf_box", "Armature", "Bone.Root", "Bone.L", "frame"}), anim::animation_system()->instances()->locate<com::Frame>({ "gltf_box", "Armature", "Bone.Root", "Bone.L", "frame"}), "set_origin", anim::Keyframes<vec3>{ {0, {0, 0, 0}, -2.f}, Loading Loading @@ -321,7 +336,7 @@ void main() { if (!gfx::object_system()->has_light(obj, dir_light)) gfx::object_system()->insert_light(obj, dir_light); if (!gfx::object_system()->has_light(obj, ambient_light)) gfx::object_system()->insert_light(obj, ambient_light); } }); }; // --- END GLTF --- Loading @@ -336,23 +351,27 @@ void main() { auto catwalk_material = gfx::material_system()->insert_material("gltf_catwalk_material", lit_skinning_shader, { "maker" }); catwalk_material->set_uniform("color", vec3{ 0.0f, 0.75f, 1.f }); index().root()->push_back<utils::GltfLoader>("walk.gltf", "models/walk.gltf", [instances, human_material](const tinygltf::Model& model) { utils::import_gltf(model, instances, "gltf_human", human_material, vec3{2, 4, 0}); const static std::string my_model_path2 = "models/walk.gltf"; handle = load_resource(my_model_path2); m_gltf_callbacks[handle] = [human_material](const std::vector<uint8_t>& data) { utils::import_gltf(data, my_model_path2, "gltf_human", human_material, vec3{2, 4, 0}); update_lights(); print_tree(com::Folder::root(), std::cout, 4); anim::animation_system()->animations()->locate<com::Folder>({"gltf_human__Armature|mixamo.com|Layer0.anim", "vec3_tracks"})->erase("mixamorig:Hips_translation.track"); }); }; // index().root()->push_back<utils::GltfLoader>("rigged_double_cube.gltf", "models/rigged_double_cube.gltf", [skeletons, instances, lit_skinning_material](const tinygltf::Model& model) { // utils::import_gltf(model, instances, "gltf_double_box", lit_skinning_material, vec3{5, 0, 0}, vec3{0, 0, 1.57}); // update_lights(); // }); index().root()->push_back<utils::GltfLoader>("dance.gltf", "models/dance.gltf", [instances, human_material](const tinygltf::Model& model) { utils::import_gltf(model, instances, "gltf_dance", nullptr, vec3{-5, 4, 0}); const static std::string dance_model_path = "models/dance.gltf"; handle = load_resource(dance_model_path); m_gltf_callbacks[handle] = [human_material](const std::vector<uint8_t>& data) { utils::import_gltf(data, dance_model_path, "gltf_dance", nullptr, vec3{-5, 4, 0}); update_lights(); }); }; // utils::import_gltf(instances, "models/catwalk.gltf", "gltf_catwalk", nullptr, vec3{8, 4, 0}); // utils::import_gltf(instances, "models/gunplay.gltf", "gltf_gunplay", nullptr); // utils::import_gltf(instances, "models/walk_and_gun.gltf", "gltf_walk_and_gun", walk_material, vec3{-2, 4, 0}/* , identity<quat>(), "gltf_human" */); Loading Loading @@ -1161,4 +1180,17 @@ void Presenter::next_round() // glFlush(); } void Presenter::on_content_changed(com::File* const sender) { if (m_gltf_callbacks.contains(sender)) { if (auto handle = dynamic_cast<lfs::ResourceHandle*>(sender)) { ASSUMPTION(handle->state() == lfs::ResourceHandle::LOADED); m_gltf_callbacks[sender](handle->data()); handle->unregister_on_content_changed(this); m_gltf_callbacks.erase(sender); } } } }