aboutsummaryrefslogtreecommitdiff
path: root/src/abc/abc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/abc/abc.h')
-rw-r--r--src/abc/abc.h177
1 files changed, 177 insertions, 0 deletions
diff --git a/src/abc/abc.h b/src/abc/abc.h
new file mode 100644
index 0000000..b86f13c
--- /dev/null
+++ b/src/abc/abc.h
@@ -0,0 +1,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