/* * Copyright (C) 2023 Christopher J. Howard * * This file is part of Antkeeper source code. * * Antkeeper source code is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Antkeeper source code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Antkeeper source code. If not, see . */ #ifndef ANTKEEPER_SCENE_RIGGED_MESH_HPP #define ANTKEEPER_SCENE_RIGGED_MESH_HPP #include #include #include #include #include namespace scene { /** * */ class rigged_mesh: public object { public: /** * Constructs a rigged mesh from a model. * * @param model Model from which the rigged mesh will be constructed. */ explicit rigged_mesh(std::shared_ptr model); /** * Constructs a model instance. */ rigged_mesh() = default; /** * Sets the model with which this model instance is associated. * * @warning This will reset all overwritten materials. */ void set_model(std::shared_ptr model); /** * Overwrites the material of a model group for this model instance. * * @param index Index of a model group. * @param material Pointer to the material which should overwrite the model group's material. A value of `nullptr` indicates the material will not be overwritten. */ void set_material(std::size_t index, std::shared_ptr material); /** * Resets all overwritten materials. */ void reset_materials(); [[nodiscard]] inline const aabb_type& get_bounds() const noexcept override { return m_bounds; } /** * Returns the model of the model instance. */ [[nodiscard]] inline const std::shared_ptr& get_model() const noexcept { return m_model; } void render(render::context& ctx) const override; /// Returns the pose of the rigged mesh. /// @{ [[nodiscard]] inline const skeleton_pose& get_pose() const noexcept { return m_pose; } [[nodiscard]] inline skeleton_pose& get_pose() noexcept { return m_pose; } /// @} private: void update_bounds(); void transformed() override; std::shared_ptr m_model; mutable std::vector m_operations; aabb_type m_bounds{{0, 0, 0}, {0, 0, 0}}; skeleton_pose m_pose; }; } // namespace scene #endif // ANTKEEPER_SCENE_RIGGED_MESH_HPP