OSDN Git Service

データ構造の改良
[qtgeoviewer/QtGeoViewer.git] / Src / LibQtGeoViewerCore / Bone.h
1 #pragma once
2
3
4
5 namespace geom
6 {
7
8
9 class BoneWeight
10 {
11 public:
12         BoneWeight(void):
13                 m_Vid(-1),
14                 m_Weight(0.0f)
15         {
16         }
17
18 public:
19         int m_Vid;
20         float m_Weight;
21 };
22
23
24 class Bone
25 {
26 public:
27         Bone(void)
28         {
29                 m_Index = -1;
30                 m_KeyIdxOffset = 0;
31         }
32
33         lm::matrix4f GetFrameTransform(int frame) const;
34
35         int GetNumFrames(void) const;
36         int GetNumFramesAbs(void) const;
37         int ConvertFrameAbsToPositive(int f) const;
38         int ConvertFramePositiveToAbs(int f) const;
39
40         lm::vec3f VertGolbalToLocal(const lm::vec3f& v) const;
41
42         bool HaSequence(void) const
43         {
44                 return GetNumFrames() != 0;
45         }
46
47         void SetOffset(const lm::matrix4f& offset);
48
49 public:
50         int m_Index;
51         std::string m_Name;
52
53         lm::matrix4f m_NodeTrans;
54
55         std::vector<BoneWeight> m_Weights;
56
57         std::vector<lm::vec3f>  m_Translate;
58         std::vector<lm::quat4f> m_Rotate;
59         std::vector<lm::vec3f>  m_Scale;
60
61         lm::matrix4f m_Offset;
62
63         int m_KeyIdxOffset;
64 };
65
66
67 class BoneNode
68 {
69 public:
70         BoneNode(void)
71         {
72                 m_Bone = NULL;
73                 m_Parent = NULL;
74         }
75
76 public:
77         lm::matrix4f m_Transform;
78         Bone* m_Bone;
79
80         BoneNode* m_Parent;
81
82         boost::ptr_vector<BoneNode> m_Children;
83 };
84
85
86 class BoneAnimation
87 {
88 public:
89         void Clear(void)
90         {
91                 m_Bones.clear();
92                 m_SrcVertPos.clear();
93                 m_RootNodes.clear();
94         }
95
96         int GetFrameMax(void) const;
97
98 public:
99         boost::ptr_vector<Bone> m_Bones;
100
101         std::vector<lm::vec3f> m_SrcVertPos;
102
103         boost::ptr_vector<BoneNode> m_RootNodes;
104 };
105
106
107 class BoneMap
108 {
109 public:
110         std::map<std::string, Bone*> Bones;
111 };
112
113
114 }