From 56586f450757e8c797a3548e62f835dcbf21be53 Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <joseph@walton-rivers.uk> Date: Sun, 19 Jun 2022 22:58:12 +0100 Subject: [PATCH] data structures for animation, not currently used --- include/fggl/animation/skeleton.hpp | 60 +++++++++++++++++++++++++++++ include/fggl/math/types.hpp | 1 + 2 files changed, 61 insertions(+) create mode 100644 include/fggl/animation/skeleton.hpp diff --git a/include/fggl/animation/skeleton.hpp b/include/fggl/animation/skeleton.hpp new file mode 100644 index 0000000..7a4169b --- /dev/null +++ b/include/fggl/animation/skeleton.hpp @@ -0,0 +1,60 @@ +/* + * This file is part of FGGL. + * + * FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * FGGL 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with FGGL. + * If not, see <https://www.gnu.org/licenses/>. + */ + +// +// Created by webpigeon on 19/06/22. +// Derived from Game Engine Architecture, 3rd Edition, Chapter 12 +// + +#ifndef FGGL_ANIMATION_SKELETON_HPP +#define FGGL_ANIMATION_SKELETON_HPP + +#include <array> +#include "fggl/math/types.hpp" + +namespace fggl::anim { + + struct Joint { + math::mat4 m_invBindPose; + math::uint8 m_parent; + }; + + struct Skeleton { + std::size_t m_size; + std::array<Joint, 255> m_joints; + }; + + struct JointPose { + math::quat m_rot; + math::vec3 m_trans; + float m_scale; + }; + + struct SkeletonPose { + Skeleton* m_skel; + JointPose* m_localPose; + math::mat4* m_globalPose; + }; + + struct SkinnedVertex { + math::vec3 m_pos; + math::vec3 m_normal; + math::vec2 m_tex; + std::array<math::uint8, 4> m_joint_idx; + std::array<float, 3> m_joint_weights; + }; + +} // namespace fggl::anim + +#endif //FGGL_ANIMATION_SKELETON_HPP diff --git a/include/fggl/math/types.hpp b/include/fggl/math/types.hpp index 936fd66..8349557 100644 --- a/include/fggl/math/types.hpp +++ b/include/fggl/math/types.hpp @@ -39,6 +39,7 @@ namespace fggl::math { constexpr float HALF_PI = M_PI_2; constexpr float TAU = PI * 2; + using uint8 = std::uint8_t; // math types (aliased for ease of use) using vec4 = glm::vec4; -- GitLab