summaryrefslogtreecommitdiff
path: root/src/win95/shpanim.h
blob: 869cc41e7334522ee47643c6efe97d6efb9a0747 (plain)
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#ifndef _shp_anim_h
#define _shp_anim_h 1


#ifdef __cplusplus

	extern "C" {

#endif


/*

	Structures for animating shapes (not morphing)

	I am using standard types to organise the
	sequences as an enum would force a complete
	recompile each time it changed

*/

typedef struct shapeanimationframe
{

	// Public variables

	
	
	// Private variables
	
	int * vertices;
	int * item_normals;
	

} SHAPEANIMATIONFRAME;


typedef struct shapeanimationsequence
{

	// Public variables

	int radius;

	int max_x;
	int max_y;
	int max_z;

	int min_x;
	int min_y;
	int min_z;
	
	
	// Private variables
	
	unsigned long num_frames;
	SHAPEANIMATIONFRAME * anim_frames;

//	unsigned long num_interpolated_frames_per_frame;
	// 0 for none

	int * vertex_normals;
	
} SHAPEANIMATIONSEQUENCE;


typedef struct shapeanimationheader
{

	// Public variables


	// Private variables
	
	unsigned long num_sequences;
	
	SHAPEANIMATIONSEQUENCE * anim_sequences;
	
	int num_shapes_using_this;  //number of shapes sharing the same shapeanimationheader

} SHAPEANIMATIONHEADER;



typedef struct shapeanimationcontroldata
{

	// Public variables

	// 16.16 fixed point
	unsigned long seconds_per_frame;
	// default is ONE_FIXED / 8
	
	unsigned long sequence_no;
	// default is 0

	// if you're not interested in setting a start and an end frame
	// then set the flag 'default_start_and_end_frames' below
	unsigned long start_frame;
	unsigned long end_frame;
	// no default values

	unsigned long default_start_and_end_frames : 1;
	// default is on
	
	unsigned long reversed : 1;
	// default is off	
	
	unsigned long stop_at_end : 1;
	// default is off	
	

	
	// Private variables

	unsigned long empty : 1;
	unsigned long stop_now : 1;
	unsigned long pause_at_end : 1;
	
	// if start_frame == end_frame
	// then do not stop unless it has done at least one frame
	unsigned long done_a_frame : 1;

	SHAPEANIMATIONSEQUENCE * sequence;

	signed long current_frame;
	signed long time_to_next_frame;

} SHAPEANIMATIONCONTROLDATA;


typedef struct shapeanimationcontroller
{

	// Public variables
	
	SHAPEANIMATIONCONTROLDATA current;
	
	SHAPEANIMATIONCONTROLDATA next;
	
	unsigned long finished : 1;
	
	
	// Private variables
	
	unsigned long playing : 1;
	
	SHAPEANIMATIONHEADER * anim_header;
	
} SHAPEANIMATIONCONTROLLER;
	
	
	
	
//////////////////////////////////////////////////////////////////////////////////
/////////////////////////////      Funtions      /////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////

struct displayblock;
struct shapeheader;

// This sets the current animation (and the next to empty)
unsigned int SetShapeAnimationSequence (struct displayblock *, SHAPEANIMATIONCONTROLDATA *);
unsigned int SetOrphanedShapeAnimationSequence (SHAPEANIMATIONCONTROLLER * sac, SHAPEANIMATIONCONTROLDATA * sacd);

// This sets the next animation (if the current is empty it will set the current)
unsigned int SetNextShapeAnimationSequence (struct displayblock *, SHAPEANIMATIONCONTROLDATA *);

// stop_now == 1 will cause the function to ignore the end_frame value
// set end_frame to -1 for no change to the ending frame of the sequence
void SetCurrentShapeAnimationToStop (struct displayblock *, unsigned long stop_now, signed long end_frame);

SHAPEANIMATIONCONTROLDATA const * GetCurrentShapeAnimationSequenceData (struct displayblock *);
SHAPEANIMATIONCONTROLDATA const * GetNextShapeAnimationSequenceData (struct displayblock *);

// pause_now == 1 will cause the function to ignore the end_frame value
// set end_frame to -1 for no change to the ending frame of the sequence
void PauseCurrentShapeAnimation (struct displayblock *, unsigned long pause_now, signed long end_frame);
void RestartCurrentShapeAnimation (struct displayblock *);

// Please use these functions, whenever you create a block of each type
void InitShapeAnimationController (SHAPEANIMATIONCONTROLLER *, struct shapeheader *);
void InitShapeAnimationControlData (SHAPEANIMATIONCONTROLDATA *);




// These are for the system

void DoAllShapeAnimations ();
	
void CopyAnimationFrameToShape (SHAPEANIMATIONCONTROLDATA *sacd, struct displayblock * dptr);
	
#ifdef __cplusplus

	};

#endif


#endif