blob: 1b64af13572fae08c81dd53683f9819dc0bda6e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#include "HLAnimationIntermediette.h"
using namespace std;
using namespace tinyxml2;
HLAnimationIntermediette::HLAnimationIntermediette()
{
limit = 0;
limbCount = 0;
frameCount = 0;
rotationValues = vector<uint16_t>();
rotationIndices = vector<RotationIndex>();
}
HLAnimationIntermediette::~HLAnimationIntermediette()
{
}
HLAnimationIntermediette* HLAnimationIntermediette::FromXML(std::string xmlPath)
{
HLAnimationIntermediette* anim = new HLAnimationIntermediette();
XMLDocument doc;
doc.LoadFile(xmlPath.c_str());
XMLElement* root = doc.RootElement();
anim->limit = root->IntAttribute("Limit");
anim->limbCount = root->IntAttribute("LimbCount");
anim->frameCount = root->IntAttribute("FrameCount");
for (XMLElement* child = root->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
{
if (string(child->Name()) == "RotationValues")
{
for (XMLElement* child2 = child->FirstChildElement(); child2 != NULL; child2 = child2->NextSiblingElement())
{
string value = child2->GetText();
anim->rotationValues.push_back(atoi(value.c_str()));
}
}
else if (string(child->Name()) == "RotationIndices")
{
for (XMLElement* child2 = child->FirstChildElement(); child2 != NULL; child2 = child2->NextSiblingElement())
anim->rotationIndices.push_back(RotationIndex(child2->IntAttribute("X"), child2->IntAttribute("Y"), child2->IntAttribute("Z")));
}
}
return anim;
}
HLAnimationIntermediette* HLAnimationIntermediette::FromZAnimation(ZAnimation* zAnim)
{
HLAnimationIntermediette* anim = new HLAnimationIntermediette();
/*anim->limit = zAnim->limit;
anim->frameCount = zAnim->frameCount;
for (uint16_t item : zAnim->rotationValues)
anim->rotationValues.push_back(item);
for (RotationIndex item : zAnim->rotationIndices)
anim->rotationIndices.push_back(item);*/
return anim;
}
ZAnimation* HLAnimationIntermediette::ToZAnimation()
{
ZAnimation* zAnim = new ZAnimation();
/*zAnim->limit = limit;
zAnim->frameCount = frameCount;
for (uint16_t item : rotationValues)
zAnim->rotationValues.push_back(item);
for (RotationIndex item : rotationIndices)
zAnim->rotationIndices.push_back(item);*/
return zAnim;
}
string HLAnimationIntermediette::OutputXML()
{
string output = "";
XMLDocument doc;
XMLElement* root = doc.NewElement("HLAnimationIntermediette");
root->SetAttribute("Limit", limit);
root->SetAttribute("LimbCount", limbCount);
root->SetAttribute("FrameCount", frameCount);
doc.InsertFirstChild(root);
XMLElement* rotValues = doc.NewElement("RotationValues");
for (int i = 0; i < rotationValues.size(); i++)
{
XMLElement* rotValue = doc.NewElement("Value");
rotValue->SetText(rotationValues[i]);
rotValues->InsertEndChild(rotValue);
}
root->InsertEndChild(rotValues);
XMLElement* rotIndices = doc.NewElement("RotationIndices");
for (int i = 0; i < rotationIndices.size(); i++)
{
XMLElement* rotIndex = doc.NewElement("Value");
rotIndex->SetAttribute("X", rotationIndices[i].x);
rotIndex->SetAttribute("Y", rotationIndices[i].y);
rotIndex->SetAttribute("Z", rotationIndices[i].z);
rotIndices->InsertEndChild(rotIndex);
}
root->InsertEndChild(rotIndices);
XMLPrinter printer;
doc.Accept(&printer);
return printer.CStr();
}
|