1 #ifndef _shp_anim_h
2 #define _shp_anim_h 1
3 
4 
5 #ifdef __cplusplus
6 
7 	extern "C" {
8 
9 #endif
10 
11 
12 /*
13 
14 	Structures for animating shapes (not morphing)
15 
16 	I am using standard types to organise the
17 	sequences as an enum would force a complete
18 	recompile each time it changed
19 
20 */
21 
22 typedef struct shapeanimationframe
23 {
24 
25 	// Public variables
26 
27 
28 
29 	// Private variables
30 
31 	int * vertices;
32 	int * item_normals;
33 
34 
35 } SHAPEANIMATIONFRAME;
36 
37 
38 typedef struct shapeanimationsequence
39 {
40 
41 	// Public variables
42 
43 	int radius;
44 
45 	int max_x;
46 	int max_y;
47 	int max_z;
48 
49 	int min_x;
50 	int min_y;
51 	int min_z;
52 
53 
54 	// Private variables
55 
56 	unsigned long num_frames;
57 	SHAPEANIMATIONFRAME * anim_frames;
58 
59 //	unsigned long num_interpolated_frames_per_frame;
60 	// 0 for none
61 
62 	int * vertex_normals;
63 
64 } SHAPEANIMATIONSEQUENCE;
65 
66 
67 typedef struct shapeanimationheader
68 {
69 
70 	// Public variables
71 
72 
73 	// Private variables
74 
75 	int num_sequences;
76 
77 	SHAPEANIMATIONSEQUENCE * anim_sequences;
78 
79 	int num_shapes_using_this;  //number of shapes sharing the same shapeanimationheader
80 
81 } SHAPEANIMATIONHEADER;
82 
83 
84 
85 typedef struct shapeanimationcontroldata
86 {
87 
88 	// Public variables
89 
90 	// 16.16 fixed point
91 	unsigned long seconds_per_frame;
92 	// default is ONE_FIXED / 8
93 
94 	unsigned long sequence_no;
95 	// default is 0
96 
97 	// if you're not interested in setting a start and an end frame
98 	// then set the flag 'default_start_and_end_frames' below
99 	unsigned long start_frame;
100 	unsigned long end_frame;
101 	// no default values
102 
103 	unsigned long default_start_and_end_frames : 1;
104 	// default is on
105 
106 	unsigned long reversed : 1;
107 	// default is off
108 
109 	unsigned long stop_at_end : 1;
110 	// default is off
111 
112 
113 
114 	// Private variables
115 
116 	unsigned long empty : 1;
117 	unsigned long stop_now : 1;
118 	unsigned long pause_at_end : 1;
119 
120 	// if start_frame == end_frame
121 	// then do not stop unless it has done at least one frame
122 	unsigned long done_a_frame : 1;
123 
124 	SHAPEANIMATIONSEQUENCE * sequence;
125 
126 	signed long current_frame;
127 	signed long time_to_next_frame;
128 
129 } SHAPEANIMATIONCONTROLDATA;
130 
131 
132 typedef struct shapeanimationcontroller
133 {
134 
135 	// Public variables
136 
137 	SHAPEANIMATIONCONTROLDATA current;
138 
139 	SHAPEANIMATIONCONTROLDATA next;
140 
141 	unsigned long finished : 1;
142 
143 
144 	// Private variables
145 
146 	unsigned long playing : 1;
147 
148 	SHAPEANIMATIONHEADER * anim_header;
149 
150 } SHAPEANIMATIONCONTROLLER;
151 
152 
153 
154 
155 //////////////////////////////////////////////////////////////////////////////////
156 /////////////////////////////      Funtions      /////////////////////////////////
157 //////////////////////////////////////////////////////////////////////////////////
158 
159 struct displayblock;
160 struct shapeheader;
161 
162 // This sets the current animation (and the next to empty)
163 unsigned int SetShapeAnimationSequence (struct displayblock *, SHAPEANIMATIONCONTROLDATA *);
164 unsigned int SetOrphanedShapeAnimationSequence (SHAPEANIMATIONCONTROLLER * sac, SHAPEANIMATIONCONTROLDATA * sacd);
165 
166 // This sets the next animation (if the current is empty it will set the current)
167 unsigned int SetNextShapeAnimationSequence (struct displayblock *, SHAPEANIMATIONCONTROLDATA *);
168 
169 // stop_now == 1 will cause the function to ignore the end_frame value
170 // set end_frame to -1 for no change to the ending frame of the sequence
171 void SetCurrentShapeAnimationToStop (struct displayblock *, unsigned long stop_now, signed long end_frame);
172 
173 SHAPEANIMATIONCONTROLDATA const * GetCurrentShapeAnimationSequenceData (struct displayblock *);
174 SHAPEANIMATIONCONTROLDATA const * GetNextShapeAnimationSequenceData (struct displayblock *);
175 
176 // pause_now == 1 will cause the function to ignore the end_frame value
177 // set end_frame to -1 for no change to the ending frame of the sequence
178 void PauseCurrentShapeAnimation (struct displayblock *, unsigned long pause_now, signed long end_frame);
179 void RestartCurrentShapeAnimation (struct displayblock *);
180 
181 // Please use these functions, whenever you create a block of each type
182 void InitShapeAnimationController (SHAPEANIMATIONCONTROLLER *, struct shapeheader *);
183 void InitShapeAnimationControlData (SHAPEANIMATIONCONTROLDATA *);
184 
185 
186 
187 
188 // These are for the system
189 
190 void DoAllShapeAnimations ();
191 
192 void CopyAnimationFrameToShape (SHAPEANIMATIONCONTROLDATA *sacd, struct displayblock * dptr);
193 
194 #ifdef __cplusplus
195 
196 	};
197 
198 #endif
199 
200 
201 #endif
202