convert line ends
[canaan.git] / prj / cam / src / motion / motschem.h
blob5622e8c349136b42dff7d0582a39d7d2635eaaec
1 /*
2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
4 */
6 // $Header: r:/t2repos/thief2/src/motion/motschem.h,v 1.6 2000/01/31 09:51:03 adurant Exp $
7 #pragma once
9 //
10 // This header contains class interface for motion schemas and
11 // motion schema sets.
13 // They are the return values from queries to the motion database, and can
14 // be used to generate motion plans.
17 #ifndef __MOTSCHEM_H
18 #define __MOTSCHEM_H
20 #include <dynarray.h>
21 #include <tagfile.h>
22 #include <objtype.h>
23 #include <label.h>
24 #include <motset.h> // for sMotStuff
25 #include <namemap.h>
26 #include <motdbtyp.h>
29 #define kMotSchemaID_Invalid -1
31 #define kMSchFlag_ArchObjSwizzle 0x1
32 #define kMSchFlag_FixedDuration 0x2
33 #define kMSchFlag_TimeWarp 0x4
34 #define kMSchFlag_Stretch 0x8
35 #define kMSchFlag_FixedDist 0x10
37 // these are the atomic units of the motion database, and the thing from
38 // which the motion system builds its plans.
39 // It's up to the app to associate data with the schema's archetype, and
40 // to know how to access that data
42 class cMotionSchema
44 public:
45 cMotionSchema();
47 ~cMotionSchema();
49 // returns motion handle for a random motion in schema
50 BOOL GetRandomMotion(int *pMotID) const;
51 BOOL GetRandomMotionInRange(int min, int max, int *pMotID) const;
52 BOOL GetMotion(int offset, int *pMotID) const;
54 void SetDuration(float duration);
55 void SetTimeWarp(float timeWarp);
56 void SetDistance(float distance);
57 void SetStretch(float timeWarp);
58 BOOL GetDuration(float *pDuration) const;
59 BOOL GetTimeWarp(float *pTimeWarp) const;
60 BOOL GetDistance(float *pDist) const;
61 BOOL GetStretch(float *pStretch) const;
63 int NumMotions() const { return m_MotRunHandleList.Size(); }
65 ObjID GetArchetype() const { return m_ArchObj; }
67 int GetIndex() const { return m_ArchIndex; }
69 int GetSchemaID() const { return m_SchemaID; }
70 void SetSchemaID(int id) { m_SchemaID = id; }
72 ulong GetFlags() const { return m_Flags; }
73 void SetFlags(ulong flags) { m_Flags=flags; }
75 // save/load
76 BOOL Save(ITagFile *pFile);
77 BOOL Load(ITagFile *pFile, cNameMap *pNameMap);
78 void SetupRunTimeData(cNameMap *pNameMap);
80 // db building
81 void AddMotion(const Label *name, const sMotStuff *pStuff);
82 void SetArchetype(int index); // index into name map provided by EndBuild and Load
84 private:
85 ulong m_Flags;
86 int m_ArchIndex;
87 ObjID m_ArchObj;
88 int m_SchemaID;
89 float m_TimeModifier;
90 float m_DistModifier;
91 cDynArray<int> m_MotIndexList;
92 cDynArray<int> m_MotRunHandleList;
95 inline void cMotionSchema::SetDuration(float duration)
97 if(m_Flags&kMSchFlag_TimeWarp)
98 m_Flags&=(~kMSchFlag_TimeWarp);
99 m_Flags|=kMSchFlag_FixedDuration;
100 m_TimeModifier=duration;
103 inline void cMotionSchema::SetTimeWarp(float timeWarp)
105 if(m_Flags&kMSchFlag_FixedDuration)
106 m_Flags&=(~kMSchFlag_FixedDuration);
107 m_Flags|=kMSchFlag_TimeWarp;
108 m_TimeModifier=timeWarp;
111 inline void cMotionSchema::SetDistance(float dist)
113 if(m_Flags&kMSchFlag_Stretch)
114 m_Flags&=(~kMSchFlag_Stretch);
115 m_Flags|=kMSchFlag_FixedDist;
116 m_DistModifier=dist;
119 inline void cMotionSchema::SetStretch(float stretch)
121 if(m_Flags&kMSchFlag_FixedDist)
122 m_Flags&=(~kMSchFlag_FixedDist);
123 m_Flags|=kMSchFlag_Stretch;
124 m_DistModifier=stretch;
127 inline BOOL cMotionSchema::GetDuration(float *pDuration) const
129 if(m_Flags&kMSchFlag_FixedDuration)
131 *pDuration=m_TimeModifier;
132 return TRUE;
134 return FALSE;
137 inline BOOL cMotionSchema::GetTimeWarp(float *pTimeWarp) const
139 if(m_Flags&kMSchFlag_TimeWarp && !(m_Flags&kMSchFlag_FixedDuration))
141 *pTimeWarp=m_TimeModifier;
142 return TRUE;
144 return FALSE;
147 inline BOOL cMotionSchema::GetDistance(float *pDist) const
149 if(m_Flags&kMSchFlag_FixedDist)
151 *pDist=m_DistModifier;
152 return TRUE;
154 return FALSE;
157 inline BOOL cMotionSchema::GetStretch(float *pStretch) const
159 if(m_Flags&kMSchFlag_Stretch && !(m_Flags&kMSchFlag_FixedDist))
161 *pStretch=m_DistModifier;
162 return TRUE;
164 return FALSE;
167 typedef cDynClassArray<cMotionSchema> cMotionSchemaSet;
169 typedef cDynArray<cMotionSchema *> cMotionSchemaPtrList;
171 #endif // motschem_h