|
@@ -26,10 +26,10 @@ Camera::Camera()
|
26
|
26
|
{
|
27
|
27
|
mId = ++mCounter;
|
28
|
28
|
mFlags = 0;
|
29
|
|
- mViewDistance = 14.0;
|
30
|
|
- mTranslateDelta = 256.0;
|
31
|
|
- mRotateDelta = HEL_DEG_TO_RAD(15.0);
|
32
|
|
- mRotateDelta2 = HEL_DEG_TO_RAD(5.0);
|
|
29
|
+ mViewDistance = 14.0f;
|
|
30
|
+ mTranslateDelta = 256.0f;
|
|
31
|
+ mRotateDelta = HEL_DEG_TO_RAD(15.0f);
|
|
32
|
+ mRotateDelta2 = HEL_DEG_TO_RAD(5.0f);
|
33
|
33
|
mFlags &= Camera_FlyMode;
|
34
|
34
|
reset();
|
35
|
35
|
}
|
|
@@ -80,13 +80,13 @@ float Camera::getYaw()
|
80
|
80
|
}
|
81
|
81
|
|
82
|
82
|
|
83
|
|
-double Camera::getRadianYaw()
|
|
83
|
+vec_t Camera::getRadianYaw()
|
84
|
84
|
{
|
85
|
85
|
return mTheta;
|
86
|
86
|
}
|
87
|
87
|
|
88
|
88
|
|
89
|
|
-double Camera::getRadianPitch()
|
|
89
|
+vec_t Camera::getRadianPitch()
|
90
|
90
|
{
|
91
|
91
|
return mTheta2;
|
92
|
92
|
}
|
|
@@ -100,9 +100,9 @@ void Camera::rotate(float angle, float x, float y, float z)
|
100
|
100
|
{
|
101
|
101
|
Quaternion t, n;
|
102
|
102
|
Matrix matrix;
|
103
|
|
- double side[4] = { 1, 0, 0, 1 };
|
104
|
|
- double up[4] = { 0, 1, 0, 1 };
|
105
|
|
- double look[4] = { 0, 0, -1, 1 };
|
|
103
|
+ vec_t side[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
|
|
104
|
+ vec_t up[4] = { 0.0f, 1.0f, 0.0f, 1.0f };
|
|
105
|
+ vec_t look[4] = { 0.0f, 0.0f, -1.0f, 1.0f };
|
106
|
106
|
unsigned int i;
|
107
|
107
|
matrix_t m;
|
108
|
108
|
|
|
@@ -113,9 +113,9 @@ void Camera::rotate(float angle, float x, float y, float z)
|
113
|
113
|
|
114
|
114
|
n.getMatrix(m);
|
115
|
115
|
matrix.setMatrix(m);
|
116
|
|
- matrix.multiply4d(side, mSide);
|
117
|
|
- matrix.multiply4d(look, mTarget);
|
118
|
|
- matrix.multiply4d(up, mUp);
|
|
116
|
+ matrix.multiply4v(side, mSide);
|
|
117
|
+ matrix.multiply4v(look, mTarget);
|
|
118
|
+ matrix.multiply4v(up, mUp);
|
119
|
119
|
|
120
|
120
|
for (i = 0; i < 3; ++i)
|
121
|
121
|
{
|
|
@@ -131,8 +131,8 @@ void Camera::rotate(float angle, float x, float y, float z)
|
131
|
131
|
void Camera::translate(float x, float y, float z)
|
132
|
132
|
{
|
133
|
133
|
int i;
|
134
|
|
- double result[4];
|
135
|
|
- double v[4];
|
|
134
|
+ vec_t result[4];
|
|
135
|
+ vec_t v[4];
|
136
|
136
|
matrix_t m;
|
137
|
137
|
Matrix matrix;
|
138
|
138
|
|
|
@@ -160,7 +160,7 @@ void Camera::translate(float x, float y, float z)
|
160
|
160
|
m[15] = 1;
|
161
|
161
|
|
162
|
162
|
matrix.setMatrix(m);
|
163
|
|
- matrix.multiply4d(v, result);
|
|
163
|
+ matrix.multiply4v(v, result);
|
164
|
164
|
|
165
|
165
|
for (i = 0; i < 3; ++i)
|
166
|
166
|
{
|
|
@@ -178,27 +178,27 @@ void Camera::translate(float x, float y, float z)
|
178
|
178
|
|
179
|
179
|
void Camera::reset()
|
180
|
180
|
{
|
181
|
|
- mTheta = 0.0;
|
182
|
|
- mTheta2 = 0.0;
|
|
181
|
+ mTheta = 0.0f;
|
|
182
|
+ mTheta2 = 0.0f;
|
183
|
183
|
|
184
|
|
- mPos[0] = 0.0;
|
185
|
|
- mPos[1] = 0.0;
|
186
|
|
- mPos[2] = 0.0;
|
|
184
|
+ mPos[0] = 0.0f;
|
|
185
|
+ mPos[1] = 0.0f;
|
|
186
|
+ mPos[2] = 0.0f;
|
187
|
187
|
|
188
|
|
- mTarget[0] = 0.0;
|
189
|
|
- mTarget[1] = 0.0;
|
|
188
|
+ mTarget[0] = 0.0f;
|
|
189
|
+ mTarget[1] = 0.0f;
|
190
|
190
|
mTarget[2] = mViewDistance;
|
191
|
191
|
|
192
|
|
- mSide[0] = 1.0;
|
193
|
|
- mSide[1] = 0.0;
|
194
|
|
- mSide[2] = 0.0;
|
|
192
|
+ mSide[0] = 1.0f;
|
|
193
|
+ mSide[1] = 0.0f;
|
|
194
|
+ mSide[2] = 0.0f;
|
195
|
195
|
|
196
|
|
- mUp[0] = 0.0;
|
197
|
|
- mUp[1] = 1.0;
|
198
|
|
- mUp[2] = 0.0;
|
|
196
|
+ mUp[0] = 0.0f;
|
|
197
|
+ mUp[1] = 1.0f;
|
|
198
|
+ mUp[2] = 0.0f;
|
199
|
199
|
|
200
|
200
|
mQ.setIdentity();
|
201
|
|
- translate(0.0, 0.0, 0.0);
|
|
201
|
+ translate(0.0f, 0.0f, 0.0f);
|
202
|
202
|
}
|
203
|
203
|
|
204
|
204
|
|
|
@@ -222,63 +222,63 @@ void Camera::command(enum camera_command cmd)
|
222
|
222
|
case CAMERA_MOVE_FORWARD:
|
223
|
223
|
if (mFlags & Camera_FlyMode)
|
224
|
224
|
{
|
225
|
|
- mPos[2] += (mTranslateDelta * cos(mTheta));
|
|
225
|
+ mPos[2] += (mTranslateDelta * cosf(mTheta));
|
226
|
226
|
}
|
227
|
227
|
|
228
|
|
- mPos[0] += (mTranslateDelta * sin(mTheta));
|
229
|
|
- mPos[1] += (mTranslateDelta * sin(mTheta2));
|
|
228
|
+ mPos[0] += (mTranslateDelta * sinf(mTheta));
|
|
229
|
+ mPos[1] += (mTranslateDelta * sinf(mTheta2));
|
230
|
230
|
break;
|
231
|
231
|
case CAMERA_MOVE_BACKWARD:
|
232
|
232
|
if (mFlags & Camera_FlyMode)
|
233
|
233
|
{
|
234
|
|
- mPos[2] -= (mTranslateDelta * cos(mTheta));
|
|
234
|
+ mPos[2] -= (mTranslateDelta * cosf(mTheta));
|
235
|
235
|
}
|
236
|
236
|
|
237
|
|
- mPos[0] -= (mTranslateDelta * sin(mTheta));
|
238
|
|
- mPos[1] -= (mTranslateDelta * sin(mTheta2));
|
|
237
|
+ mPos[0] -= (mTranslateDelta * sinf(mTheta));
|
|
238
|
+ mPos[1] -= (mTranslateDelta * sinf(mTheta2));
|
239
|
239
|
break;
|
240
|
240
|
case CAMERA_MOVE_LEFT:
|
241
|
|
- mPos[0] -= (mTranslateDelta * sin(mTheta - 90.0f));
|
242
|
|
- mPos[2] -= (mTranslateDelta * cos(mTheta - 90.0f));
|
|
241
|
+ mPos[0] -= (mTranslateDelta * sinf(mTheta - 90.0f));
|
|
242
|
+ mPos[2] -= (mTranslateDelta * cosf(mTheta - 90.0f));
|
243
|
243
|
break;
|
244
|
244
|
case CAMERA_MOVE_RIGHT:
|
245
|
|
- mPos[0] -= (mTranslateDelta * sin(mTheta + 90.0f));
|
246
|
|
- mPos[2] -= (mTranslateDelta * cos(mTheta + 90.0f));
|
|
245
|
+ mPos[0] -= (mTranslateDelta * sinf(mTheta + 90.0f));
|
|
246
|
+ mPos[2] -= (mTranslateDelta * cosf(mTheta + 90.0f));
|
247
|
247
|
break;
|
248
|
248
|
case CAMERA_ROTATE_UP:
|
249
|
249
|
if (mTheta2 < (M_PI / 2)) {
|
250
|
250
|
mTheta2 += mRotateDelta2;
|
251
|
|
- rotate(mTheta2, 1.0, 0.0, 0.0);
|
|
251
|
+ rotate(mTheta2, 1.0f, 0.0f, 0.0f);
|
252
|
252
|
}
|
253
|
253
|
break;
|
254
|
254
|
case CAMERA_ROTATE_DOWN:
|
255
|
255
|
if (mTheta2 > -(M_PI / 2)) {
|
256
|
256
|
mTheta2 -= mRotateDelta2;
|
257
|
|
- rotate(mTheta2, 1.0, 0.0, 0.0);
|
|
257
|
+ rotate(mTheta2, 1.0f, 0.0f, 0.0f);
|
258
|
258
|
}
|
259
|
259
|
break;
|
260
|
260
|
case CAMERA_ROTATE_RIGHT:
|
261
|
261
|
mTheta += mRotateDelta;
|
262
|
|
- rotate(mTheta, 0.0, 1.0, 0.0);
|
|
262
|
+ rotate(mTheta, 0.0f, 1.0f, 0.0f);
|
263
|
263
|
break;
|
264
|
264
|
case CAMERA_ROTATE_LEFT:
|
265
|
265
|
mTheta -= mRotateDelta;
|
266
|
|
- rotate(mTheta, 0.0, 1.0, 0.0);
|
|
266
|
+ rotate(mTheta, 0.0f, 1.0f, 0.0f);
|
267
|
267
|
break;
|
268
|
268
|
case CAMERA_MOVE_UP:
|
269
|
|
- mPos[1] -= mTranslateDelta / 2.0;
|
270
|
|
- mTarget[1] -= mTranslateDelta / 2.0;
|
|
269
|
+ mPos[1] -= mTranslateDelta / 2.0f;
|
|
270
|
+ mTarget[1] -= mTranslateDelta / 2.0f;
|
271
|
271
|
break;
|
272
|
272
|
case CAMERA_MOVE_DOWN:
|
273
|
|
- mPos[1] += mTranslateDelta / 2.0;
|
274
|
|
- mTarget[1] += mTranslateDelta / 2.0;
|
|
273
|
+ mPos[1] += mTranslateDelta / 2.0f;
|
|
274
|
+ mTarget[1] += mTranslateDelta / 2.0f;
|
275
|
275
|
break;
|
276
|
276
|
case CAMERA_SPEED_UP:
|
277
|
277
|
++mTranslateDelta;
|
278
|
278
|
break;
|
279
|
279
|
case CAMERA_SPEED_DOWN:
|
280
|
|
- if (--mTranslateDelta < 0.0)
|
281
|
|
- mTranslateDelta = 1.0;
|
|
280
|
+ if (--mTranslateDelta < 0.0f)
|
|
281
|
+ mTranslateDelta = 1.0f;
|
282
|
282
|
break;
|
283
|
283
|
default:
|
284
|
284
|
;
|
|
@@ -289,7 +289,7 @@ void Camera::command(enum camera_command cmd)
|
289
|
289
|
//! \fixme Mostly invalid for QUAT_CAM (can rotate on XYZ)
|
290
|
290
|
bool Camera::isBehind(int x, int z)
|
291
|
291
|
{
|
292
|
|
- double bTheta, bCameraX, bCameraZ, Distance;
|
|
292
|
+ vec_t bTheta, bCameraX, bCameraZ, Distance;
|
293
|
293
|
|
294
|
294
|
|
295
|
295
|
// Set up a "virtual camera" a huge distance behind us
|
|
@@ -299,14 +299,14 @@ bool Camera::isBehind(int x, int z)
|
299
|
299
|
bTheta -= HEL_2_PI;
|
300
|
300
|
|
301
|
301
|
// 64k is a fair distance away...
|
302
|
|
- bCameraX = (65536.0 * sin(bTheta)) + mPos[0];
|
303
|
|
- bCameraZ = (65536.0 * cos(bTheta)) + mPos[2];
|
|
302
|
+ bCameraX = (65536.0f * sinf(bTheta)) + mPos[0];
|
|
303
|
+ bCameraZ = (65536.0f * cosf(bTheta)) + mPos[2];
|
304
|
304
|
|
305
|
305
|
bCameraX -= x;
|
306
|
306
|
bCameraZ -= z;
|
307
|
|
- Distance = sqrt((bCameraX * bCameraX) + (bCameraZ * bCameraZ));
|
|
307
|
+ Distance = sqrtf((bCameraX * bCameraX) + (bCameraZ * bCameraZ));
|
308
|
308
|
|
309
|
|
- return (Distance < 65536.0);
|
|
309
|
+ return (Distance < 65536.0f);
|
310
|
310
|
}
|
311
|
311
|
|
312
|
312
|
|
|
@@ -318,9 +318,9 @@ void Camera::setSpeed(float s)
|
318
|
318
|
|
319
|
319
|
void Camera::update()
|
320
|
320
|
{
|
321
|
|
- mTarget[2] = (mViewDistance * cos(mTheta)) + mPos[2];
|
322
|
|
- mTarget[0] = (mViewDistance * sin(mTheta)) + mPos[0];
|
323
|
|
- mTarget[1] = (mViewDistance * sin(mTheta2)) + mPos[1]; // + height_offset;
|
|
321
|
+ mTarget[2] = (mViewDistance * cosf(mTheta)) + mPos[2];
|
|
322
|
+ mTarget[0] = (mViewDistance * sinf(mTheta)) + mPos[0];
|
|
323
|
+ mTarget[1] = (mViewDistance * sinf(mTheta2)) + mPos[1]; // + height_offset;
|
324
|
324
|
}
|
325
|
325
|
|
326
|
326
|
|