]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/qdata_heretic2/joints.h
Merge branch 'master' into divVerent/farplanedist-sky-fix
[xonotic/netradiant.git] / tools / quake2 / qdata_heretic2 / joints.h
1 /*
2    Copyright (C) 1999-2006 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 #ifndef JOINTS_H
23 #define JOINTS_H
24
25 #ifdef _HERETIC2_
26 #include "angles.h"
27 #endif
28
29 //typedef float vec3_t[3];
30 //typedef unsigned char byte;
31
32 #ifndef _WIN32
33 #define stricmp strcasecmp
34 #define strcmpi strcasecmp
35 #endif
36
37 typedef struct Placement_s
38 {
39         vec3_t origin;
40         vec3_t direction;
41         vec3_t up;
42 } Placement_t;
43
44 #if 1
45 typedef struct QDataJoint_s
46 {
47         Placement_t placement;
48         vec3_t rotation;
49 } QDataJoint_t;
50 #endif
51
52 typedef struct ArrayedListNode_s
53 {
54         int data;
55         int next;
56         int inUse;
57 } ArrayedListNode_t;
58
59 #define ARRAYEDLISTNODE_NULL -1
60
61 typedef struct JointAngles_s
62 {
63         float angles[3];
64         int children;
65         int created;
66 } JointAngles_t;
67
68 typedef struct JointAngles2_s
69 {
70         float angles[3];
71         int children;
72         int changed[3];
73         int inUse;
74 } JointAngles2_t;
75
76 #define MAX_MODELJOINTS         256
77 #define MAX_MODELJOINTNODES     255
78
79 extern JointAngles_t jointAngles[MAX_MODELJOINTS];
80 extern JointAngles2_t jointAngles2[MAX_MODELJOINTS];
81
82 extern ArrayedListNode_t jointAngleNodes[MAX_MODELJOINTNODES];
83
84 // Skeletal structures enums
85 enum {
86         SKEL_RAVEN = 0,
87         SKEL_BOX,
88         NUM_SKELETONS
89 };
90
91 // Raven Skeletal structures enums
92 enum {
93         RAVEN_WAIST1 = 0,
94         RAVEN_WAIST2 = 1,
95         RAVEN_HEAD = 2,
96         NUM_JOINTS_RAVEN
97 };
98
99 // Box Skeletal structures enums
100 enum {
101         BOX_CENTER = 0,
102         NUM_JOINTS_BOX
103 };
104
105 extern int numJointsForSkeleton[];
106 extern char *RAVEN_SKEL_NAMES[];
107
108 #define J_NEW_SKELETON      0x00001000
109 #define J_YAW_CHANGED       0x00002000
110 #define J_PITCH_CHANGED     0x00004000
111 #define J_ROLL_CHANGED      0x00008000
112 #define MAX_JOINTS          0x00000fff
113 /*
114    inline int GetFreeNode(ArrayedListNode_t *nodeArray, int max)
115    {    // yeah, I know this is a sucky, inefficient way to do this, but I didn't feel like taking the time to write a real resource manager in C
116     int i;
117
118     for(i = 0; i < max; ++i)
119     {
120         if(!nodeArray[i].inUse)
121         {
122             nodeArray[i].inUse = 1;
123             return i;
124         }
125     }
126
127     assert(0);
128     return -1;
129    }
130
131    inline void FreeNode(ArrayedListNode_t *nodeArray, int index)
132    {
133     nodeArray[index].inUse = 0;
134    }
135  */
136 int CreateSkeleton( int structure );
137 void CreateSkeletonAtIndex( int structure, int index );
138 void FreeSkeleton( int structure, int index );
139 void SetJointAngle( int jointIndex, int angleIndex, float angle );
140 float ModifyJointAngle( int jointIndex, int angleIndex, float deltaAngle );
141 int ZeroJointAngle( int jointIndex, int angleIndex, float angVel );
142 int ApplyAngVelToJoint( int jointIndex, int angleIndex, float angVel, float destAng );
143
144 #endif