-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit.h
149 lines (130 loc) · 3.37 KB
/
unit.h
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
#ifndef __MKSN_GRAPHICS_UNIT__
#define __MKSN_GRAPHICS_UNIT__
#include <model-iqm.h>
typedef enum
{
ANIM_IDLE,
AMIN_WALKING,
ANIM_RUNNING,
ANIM_DEATH,
ANIM_T_SIZE // always always aaalways prepend values to thiso
} animation_t;
struct ov_model;
struct ov_animation;
struct ov_skin;
struct ov_anim_txlate {
int key;
int anim;
};
struct ov_pose {
float translate[3];
float rotate[4];
float scale[3];
};
struct ov_bone {
char *name;
int parent;
struct ov_pose bind_pose;
float bind_matrix[16];
float diff[16];
float inv_bind_matrix[16];
float abs_bind_matrix[16];
float anim_matrix[16];
};
struct ov_skeleton {
int num_bones;
struct ov_bone *bones;
};
struct ov_animation {
char *dir;
char *name;
int first;
int count;
int cap;
float rate;
int loop;
struct ov_skeleton *skeleton;
struct ov_pose **poses;
int num_frames;
};
struct ov_animations {
struct ov_anim_txlate **at_table;
int num_anims;
struct ov_animation **anims;
};
struct ov_mesh {
char *name;
int material;
int first;
int count;
int first_vert;
int num_vertex;
float *position;
float *normal;
float *texcoord;
float *color;
int element_count;
int *element;
int *blendindex;
int *blendweight;
float *aposition;
float *anormal;
};
struct ov_skin {
struct ov_model *model;
char *attachement_bone;
};
struct ov_model {
char *dir;
int num_triangles;
int num_vertices;
int num_meshes;
struct ov_skeleton *skeleton;
struct ov_mesh *meshes;
float *pos;
float *norm;
float *texcoord;
int *triangles;
unsigned char *blend_index;
unsigned char *blend_weight;
struct ov_bounds *bounds;
float (*outbone)[16];
float (*outskin)[16];
struct iqm_pose *outpose;
float *dpos;
float *dnorm;
float min[3];
float max[3];
float radius;
};
struct ov_unit
{
struct ov_model *model;
struct ov_animations *animations;
struct ov_skin *skins;
};
#if 0
struct ov_animation {
struct iqm_skeleton *skeleton;
struct iqm_pose **poses;
char *name;
int first;
int count;
struct ov_anim_txlate **at_table;
};
#endif
struct ov_unit *ov_create_unit ();
int ov_get_number_anims (struct ov_unit *unit);
int ov_add_animation (struct ov_unit *unit,
char *animation_fname,
animation_t animation_key);
int ov_set_model (struct ov_unit *unit,
char *model_fname);
void ov_draw_static (struct ov_unit *du);
void ov_draw_bones (struct ov_unit *du);
void ov_draw_anim_bones (struct ov_unit *du);
void ov_animate (struct ov_unit *du,
int a,
int f,
float t);
#endif