-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCAMRDATA.HXX
189 lines (173 loc) · 5.87 KB
/
CAMRDATA.HXX
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
/* ========================================================================
Copyright (c) 1990,1996 Synergistic Software
All Rights Reserved
======================================================================== */
#ifndef _CAMRDATA_HXX
#define _CAMRDATA_HXX
/* ------------------------------------------------------------------------
Sub Includes
------------------------------------------------------------------------ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#if !defined(_CAMERA_H)
#include "camera.h"
#endif
/* ------------------------------------------------------------------------
Defines and Compile Flags
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Enums
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Typedefs
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Macros
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Prototypes
------------------------------------------------------------------------ */
// This class holds Camera Target data for the SCENE Keys and the Self Running
// demo.
enum {
NO_TARGET_REQUESTED,
SWOOP_CAMERA,
MOVE_CAMERA_EVENLY,
ROTATE_SWOOP_CAMERA,
ROTATE_CAMERA_EVENLY
};
class CAMERA_DATA {
public:
void mfInitVals();
void mfSetCameraData(LONG /* X */,
LONG /* Y */,
LONG /* Z */,
LONG /* Angle */,
LONG /* Pitch */,
LONG /* Roll */);
void mfSetCamera();
void mfMoveCamera();
void mfSwoopCamera();
BOOL mfIsAtCameraPosition();
void mfWriteData (FILE *);
BOOL mfReadData (char * /* cpBuffer */ );
protected:
private:
void *operator new (size_t stAllocateBlock); // Can't use new/delete
void operator delete (void *p);
// A CAMERA is overkill here.
LONG fx;
LONG fy;
LONG fz;
LONG fa;
LONG fp;
LONG fr; // At the moment the engine doesn't support roll.
};
/* ========================================================================
Function - mfInitVals
Description - initialize the member data.
Returns -
======================================================================== */
inline void CAMERA_DATA::mfInitVals()
{
fx = 0;
fy = 0;
fz = 0;
fa = 0;
fp = 0;
fr = 0;
}
/* ========================================================================
Function - mfSetCameraData
Description -
Returns -
======================================================================== */
inline void CAMERA_DATA::mfSetCameraData(
LONG X,
LONG Y,
LONG Z,
LONG Angle,
LONG Pitch,
LONG /* Roll */)
{
fx = X;
fy = Y;
fz = Z;
fa = Angle;
fp = Pitch;
}
/* ========================================================================
Function - mfSetCamera
Description - Move the camera to this absolute position.
Returns -
======================================================================== */
inline void CAMERA_DATA::mfSetCamera()
{
SetCameraPosition(&camera, fx, fy, fz, fa, fp);
}
/* ========================================================================
Function - mfMoveCamera
Description - Move the camera to this position as if the user pushed the
camera movement keys.
Returns -
======================================================================== */
inline void CAMERA_DATA::mfMoveCamera()
{
// Do the camera swoop.
SetCameraTarget(&camera, fx, fy, fz, fa, fp, FALSE);
}
/* ========================================================================
Function - mfSwoopCamera
Description - Move the camera to this position with accelleration and
decelleration..
Returns -
======================================================================== */
inline void CAMERA_DATA::mfSwoopCamera()
{
// Do the camera swoop.
SetCameraTarget(&camera, fx, fy, fz, fa, fp, TRUE);
}
/* ========================================================================
Function - mfIsAtCameraPosition.
Description - For testing to see if you need to keep waiting for the Move
Camera call.
Returns -
======================================================================== */
inline BOOL CAMERA_DATA::mfIsAtCameraPosition()
{
// return ( (CAMERA_INT_VAL(camera.x) == fx &&
// CAMERA_INT_VAL(camera.y) == fy &&
// camera.z == fz &&
// camera.a == fa &&
// camera.p == fp
// ) ? TRUE : FALSE);
return(camera.TargetRequested== NO_TARGET_REQUESTED);
}
/* ========================================================================
Function - mfReadData
Description - Read the data from the buffer
Returns - TRUE or FALSE if successful
======================================================================== */
inline BOOL CAMERA_DATA::mfReadData (char * cpBuffer)
{
LONG fr;
return ((6 == sscanf(cpBuffer, "%ld %ld %ld %ld %ld %ld",
&fx,
&fy,
&fz,
&fa,
&fp,
&fr)) ? TRUE : FALSE);
}
/* ========================================================================
Function - mfWriteData
Description - Write the data back to the scene file.
Returns -
======================================================================== */
inline void CAMERA_DATA::mfWriteData (FILE *fp)
{
fprintf(fp,"%ld\t%ld\t%ld\t%ld\t%ld\t%ld\n", fx, fy, fz, fa, fp, 0);
}
#endif // _CAMRDATA_HXX