]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/qdata_heretic2/qcommon/skeletons.c
eol style
[xonotic/netradiant.git] / tools / quake2 / qdata_heretic2 / qcommon / skeletons.c
1 /*
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 //
23 // Skeletons.c
24 //
25
26 #include "skeletons.h"
27
28 char *skeletonRootNames[] =
29 {
30         "RAVEN_ROOT",
31         "BOX_ROOT",
32         "BEETLE_ROOT",
33         "ELFLORD_ROOT",
34         "PLAGUELF_ROOT",
35         "ELF_BACKROOT",
36 };
37
38 int skeletonRNameOffsets[] =
39 {
40         0,      // RAVEN
41         1,      // BOX
42         2,      // BEETLE
43         3,      // ELFLORD
44         4,      // PLAGUE ELF
45         5,      // CORVUS
46 };
47
48 char *skeletonJointNames[] =
49 {
50         "RAVEN_LOWERBACK",      // 0
51         "RAVEN_UPPERBACK",
52         "RAVEN_NECK",
53         "BOX_CENTER",           // 3
54         "BEETLE_NECK",          // 4
55         "BEETLE_HEAD",
56         "PLAGUELF_BACKB",       // 6
57         "PLAGUELF_BACKC",
58         "PLAGUELF_NECK",
59         "ELF_BACKB",            // 9
60         "ELF_BACKC",
61         "ELF_NECKB",
62 };
63
64 int skeletonNameOffsets[] =
65 {
66         0,      // RAVEN
67         3,      // BOX
68         4,      // BEETLE
69         -1,     // ELFLORD
70         6,      // PLAGUE ELF
71         9,      // CORVUS
72 };
73
74 char *skeletonEffectorNames[] =
75 {
76         "BEETLE_EYES",          // 0
77         "CORVUS_EYES",          // 1
78 };
79
80 int skeletonENameOffsets[] =
81 {
82         -1,     // RAVEN
83         -1,     // BOX
84         0,      // BEETLE
85         -1,     // ELFLORD
86         1,      // PLAGUE ELF
87 };
88
89 int numJointsInSkeleton[] = 
90 {
91         NUM_JOINTS_RAVEN,
92         NUM_JOINTS_BOX,
93         NUM_JOINTS_BEETLE,
94         NUM_JOINTS_ELFLORD,
95         NUM_JOINTS_PLAGUE_ELF,
96         NUM_JOINTS_CORVUS,
97 };
98
99 int numNodesInSkeleton[] =
100 {
101         2,      // RAVEN
102         0,      // BOX
103         1,      // BEETLE
104         -1,     // ELFLORD
105         2,      // PLAGUE ELF
106         2,      // CORVUS
107 };
108
109 void CreateRavenSkel(void *g_skeletalJoints, size_t jointSize, struct ArrayedListNode_s *g_jointNodes, int root);
110 void CreateBoxSkel(void *g_skeletalJoints, size_t jointSize, struct ArrayedListNode_s *g_jointNodes, int root);
111 void CreateBeetleSkel(void *g_skeletalJoints, size_t jointSize, ArrayedListNode_t *g_jointNodes, int rootIndex);
112 void CreateElfLordSkel(void *g_skeletalJoints, size_t jointSize, ArrayedListNode_t *g_jointNodes, int rootIndex);
113 void CreatePlagueElfSkel(void *g_skeletalJoints, size_t jointSize, ArrayedListNode_t *g_jointNodes, int rootIndex);
114
115 CreateSkeleton_t SkeletonCreators[NUM_SKELETONS] =
116 {
117         CreateRavenSkel,
118         CreateBoxSkel,
119         CreateBeetleSkel,
120         CreateElfLordSkel,
121         CreatePlagueElfSkel,
122         CreatePlagueElfSkel,    // Corvus has the same structure as the Plague Elf
123 };
124
125 void CreateRavenSkel(void *g_skeletalJoints, size_t jointSize, ArrayedListNode_t *g_jointNodes, int rootIndex)
126 {
127         char *root;
128         int *children;
129         int nodeIndex;
130
131         root = (char *)g_skeletalJoints + rootIndex * jointSize;
132
133         children = (int *)(root + RAVEN_HEAD * jointSize);
134         *children = ARRAYEDLISTNODE_NULL;
135
136         nodeIndex = GetFreeNode(g_jointNodes, MAX_ARRAYED_JOINT_NODES);
137
138         children = (int *)(root + RAVEN_UPPERBACK * jointSize);
139         *children = nodeIndex;
140
141         g_jointNodes[nodeIndex].data = rootIndex + RAVEN_HEAD;
142         g_jointNodes[nodeIndex].next = ARRAYEDLISTNODE_NULL;
143
144         nodeIndex = GetFreeNode(g_jointNodes, MAX_ARRAYED_JOINT_NODES);
145
146         children = (int *)(root + RAVEN_LOWERBACK * jointSize);
147         *children = nodeIndex;
148
149         g_jointNodes[nodeIndex].data = rootIndex + RAVEN_UPPERBACK;
150         g_jointNodes[nodeIndex].next = ARRAYEDLISTNODE_NULL;
151 }
152
153 void CreateBoxSkel(void *g_skeletalJoints, size_t jointSize, ArrayedListNode_t *g_jointNodes, int rootIndex)
154 {
155         char *root;
156         int *children;
157
158         root = (char *)g_skeletalJoints + rootIndex * jointSize;
159
160         children = (int *)(root + RAVEN_HEAD * jointSize);
161         *children = ARRAYEDLISTNODE_NULL;
162 }
163
164 void CreateBeetleSkel(void *g_skeletalJoints, size_t jointSize, ArrayedListNode_t *g_jointNodes, int rootIndex)
165 {
166         char *root;
167         int *children;
168         int nodeIndex;
169
170         root = (char *)g_skeletalJoints + rootIndex * jointSize;
171
172         children = (int *)(root + BEETLE_HEAD * jointSize);
173         *children = ARRAYEDLISTNODE_NULL;
174
175         nodeIndex = GetFreeNode(g_jointNodes, MAX_ARRAYED_JOINT_NODES);
176
177         children = (int *)(root + BEETLE_NECK * jointSize);
178         *children = nodeIndex;
179
180         g_jointNodes[nodeIndex].data = rootIndex + BEETLE_HEAD;
181         g_jointNodes[nodeIndex].next = ARRAYEDLISTNODE_NULL;
182 }
183
184 void CreateElfLordSkel(void *g_skeletalJoints, size_t jointSize, ArrayedListNode_t *g_jointNodes, int rootIndex)
185 {
186         char *root;
187         int *children;
188         int nodeIndex;
189
190         root = (char *)g_skeletalJoints + rootIndex * jointSize;
191
192         children = (int *)(root + BEETLE_HEAD * jointSize);
193         *children = ARRAYEDLISTNODE_NULL;
194
195         nodeIndex = GetFreeNode(g_jointNodes, MAX_ARRAYED_JOINT_NODES);
196
197         children = (int *)(root + BEETLE_NECK * jointSize);
198         *children = nodeIndex;
199
200         g_jointNodes[nodeIndex].data = rootIndex + BEETLE_HEAD;
201         g_jointNodes[nodeIndex].next = ARRAYEDLISTNODE_NULL;
202 }
203
204 void CreatePlagueElfSkel(void *g_skeletalJoints, size_t jointSize, ArrayedListNode_t *g_jointNodes, int rootIndex)
205 {
206         char *root;
207         int *children;
208         int nodeIndex;
209
210         root = (char *)g_skeletalJoints + rootIndex * jointSize;
211
212         children = (int *)(root + PLAGUE_ELF_HEAD * jointSize);
213         *children = ARRAYEDLISTNODE_NULL;
214
215         nodeIndex = GetFreeNode(g_jointNodes, MAX_ARRAYED_JOINT_NODES);
216
217         children = (int *)(root + PLAGUE_ELF_UPPERBACK * jointSize);
218         *children = nodeIndex;
219
220         g_jointNodes[nodeIndex].data = rootIndex + PLAGUE_ELF_HEAD;
221         g_jointNodes[nodeIndex].next = ARRAYEDLISTNODE_NULL;
222
223         nodeIndex = GetFreeNode(g_jointNodes, MAX_ARRAYED_JOINT_NODES);
224
225         children = (int *)(root + PLAGUE_ELF_LOWERBACK * jointSize);
226         *children = nodeIndex;
227
228         g_jointNodes[nodeIndex].data = rootIndex + PLAGUE_ELF_UPPERBACK;
229         g_jointNodes[nodeIndex].next = ARRAYEDLISTNODE_NULL;
230 }
231
232