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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
#ifndef ABC_H
#define ABC_H
#include <rez/file.h>
#include <cstdint>
#include <list>
#include <memory>
#include <vector>
class abc
{
public:
abc();
int parse(rez::file &f);
private:
struct vector
{
float x, y, z;
};
struct rotation
{
vector v;
float w;
};
struct weight
{
uint32_t node_index;
vector location;
float bias;
};
struct vertex
{
std::vector<weight> weights;
vector vertex, normal;
};
struct triangle
{
float a, b;
uint16_t trifs;
};
struct piece
{
uint16_t tex_index;
uint32_t specular_power, specular_scale, lod_weight, n_tris;
std::string name;
std::vector<triangle> triangles;
std::vector<vertex> vertices;
};
struct set
{
std::string name;
std::vector<float> weights;
};
struct node
{
std::string name;
uint16_t transform_index;
uint8_t flags;
rotation matrix[4];
std::list<node> children;
};
struct header
{
uint32_t version, n_keyframe, n_anim, n_nodes, n_pieces, n_children,
n_triangles, n_vertices, n_vertweights, n_lod, n_socket,
n_weightsets, n_strings, n_strlen;
};
struct item
{
vector pos;
rotation rot;
};
struct childmodel
{
std::string name;
std::vector<item> items;
};
struct keyframe
{
std::string cmd;
uint32_t time;
};
struct animitem
{
abc::item item;
uint32_t unknown, unknown2;
};
struct nodeanim
{
std::vector<animitem> animitems;
};
struct animation
{
std::string name;
vector dimensions;
uint32_t compression_type, interp_time;
std::vector<keyframe> keyframes;
std::vector<nodeanim> nodeanims;
};
struct socket
{
std::string name;
uint32_t node_index;
rotation quat;
vector pos;
};
struct childanim
{
std::string name;
vector dimensions, translation;
};
struct animbinding
{
std::vector<childanim> childanims;
};
int parse_header(rez::file &f);
int parse_pieces(rez::file &f);
int parse_nodes(rez::file &f);
int parse_sets(rez::file &f);
int parse_childmodels(rez::file &f);
int parse_animation(rez::file &f);
int parse_sockets(rez::file &f);
int parse_animbindings(rez::file &f);
int parse_hitgroups(rez::file &f);
int parse(rez::file &f, std::string &name) const;
int parse(rez::file &f, node &parent);
int parse(rez::file &f, piece &piece) const;
int parse(rez::file &f, triangle &triangle) const;
int parse(rez::file &f, vertex &vertex) const;
int parse(rez::file &f, weight &weight) const;
int parse(rez::file &f, vector &vector) const;
int parse(rez::file &f, rotation &rot) const;
int parse(rez::file &f, set &set) const;
int parse(rez::file &f, childmodel &cm, bool self = false) const;
int parse(rez::file &f, item &item) const;
int parse(rez::file &f, animation &animation) const;
int parse(rez::file &f, keyframe &keyframe) const;
int parse(rez::file &f, nodeanim &nodeanim, uint32_t n_keyframes) const;
int parse(rez::file &f, animitem &animitem) const;
int parse(rez::file &f, socket &socket) const;
int parse(rez::file &f, animbinding &animbinding) const;
int parse(rez::file &f, childanim &childanim) const;
int print(const node &node, unsigned level) const;
size_t count(const node &node) const;
node root;
header header;
std::vector<piece> pieces;
std::vector<abc::set> sets;
std::vector<childmodel> childmodels;
std::vector<animation> animations;
std::vector<socket> sockets;
std::vector<animbinding> animbindings;
float int_radius;
};
#endif
|