61{
65 f32 dx, dz;
66 f32 x, y, z;
67
68 curRig = prevRig;
69 curSettings = *prevSettingsPtr;
70 x = x1;
71 y = y1;
72 z = z1;
73
79 } else {
80 switch (curSettings->
type) {
85 break;
87 break;
89 if (curSettings->
flag) {
90 f32 Ax = curSettings->
points.two.Ax;
91 f32 Az = curSettings->
points.two.Az;
92 f32 Bx = curSettings->
points.two.Bx;
93 f32 Bz = curSettings->
points.two.Bz;
94
95 f32 ABx = (Bx - Ax);
96 f32 ABz = (Bz - Az);
97
98 f32 perpdot = ABx * (z - Bz) - ABz * (x - Bx);
99 f32 dist2 =
SQ(ABx) +
SQ(ABz);
100
101
102 curRig->
targetPos.
x = Bx - ABz * (perpdot / dist2);
104 curRig->
targetPos.
z = Bz + ABx * (perpdot / dist2);
105 } else {
109 }
110 break;
112 {
113 f32 Ax = curSettings->
points.two.Ax;
114 f32 Az = curSettings->
points.two.Az;
115 f32 Bx = curSettings->
points.two.Bx;
116 f32 Bz = curSettings->
points.two.Bz;
117
118 f32 ABx = Bx - Ax;
119 f32 ABz = Bz - Az;
120
121
122 f32 t = (ABx * (x - Ax) + ABz * (z - Az)) / (
SQ(ABx) +
SQ(ABz));
123 f32 Px = Ax + t * ABx;
124 f32 Pz = Az + t * ABz;
125
126
127 f32 orthoX = x - Px;
128 f32 orthoZ = z - Pz;
129
130
131 if (t < 0.0f) {
132 Px = Ax;
133 Pz = Az;
134 } else if (t > 1.0f) {
135 Px = Bx;
136 Pz = Bz;
137 }
138 if (!curSettings->
flag) {
139 Px += orthoX;
140 Pz += orthoZ;
141 }
142
146 }
147 break;
149 if (curSettings->
flag) {
150 f32 Ax = curSettings->
points.two.Ax;
151 f32 Az = curSettings->
points.two.Az;
152 f32 Bx = curSettings->
points.two.Bx;
153 f32 Bz = curSettings->
points.two.Bz;
154
155 f32 ABx = Bx - Ax;
156 f32 ABz = Bz - Az;
157 f32 camRadius =
sqrtf(
SQ(ABx) +
SQ(ABz));
158
159
160 f32 dx = x - Ax;
161 f32 dz = z - Az;
163
164 if (curRadius != 0.0f) {
165
166 curRig->
targetPos.
x = Ax + dx * (camRadius / curRadius);
168 curRig->
targetPos.
z = Az + dz * (camRadius / curRadius);
169 }
170 } else {
174 }
175 break;
179 break;
180 }
181 }
182 }
183
184 curRig = newRig;
185 curSettings = *curSettingsPtr;
186 x = x2;
187 y = y2;
188 z = z2;
189
190 if (curSettings == NULL) {
194 } else {
195 switch (curSettings->
type) {
200 break;
202 {
203 f32 Ax = curSettings->
points.two.Ax;
204 f32 Az = curSettings->
points.two.Az;
205 f32 Bx = curSettings->
points.two.Bx;
206 f32 By = curSettings->
points.two.By;
207 f32 Bz = curSettings->
points.two.Bz;
208
209 f32 ABx = Bx - Ax;
210 f32 ABz = Bz - Az;
211
220 }
221 break;
223 dx = curSettings->
points.two.Bx - curSettings->
points.two.Ax;
224 dz = curSettings->
points.two.Bz - curSettings->
points.two.Az;
229
230 if (curSettings->
flag) {
231 f32 Ax = curSettings->
points.two.Ax;
232 f32 Az = curSettings->
points.two.Az;
233 f32 Bx = curSettings->
points.two.Bx;
234 f32 Bz = curSettings->
points.two.Bz;
235
236 f32 ABx = Bx - Ax;
237 f32 ABz = Bz - Az;
238
239 f32 perpdot = ABx * (z - Bz) - ABz * (x - Bx);
240 f32 dist2 =
SQ(ABx) +
SQ(ABz);
241
242
243 curRig->
targetPos.
x = Bx - ABz * (perpdot / dist2);
245 curRig->
targetPos.
z = Bz + ABx * (perpdot / dist2);
246 } else {
250 }
251
252 if (changingZone) {
253 if (*interpAlpha != 1.0f) {
254 prevSettings = *prevSettingsPtr;
258 && prevSettings->
type == curSettings->
type
262 && prevSettings->
flag != curSettings->
flag
263 ) {
264 *interpAlpha = 1.0f;
265 }
266 }
267 }
268 break;
270 {
271 f32 Ax = curSettings->
points.two.Ax;
272 f32 Az = curSettings->
points.two.Az;
273 f32 Bx = curSettings->
points.two.Bx;
274 f32 Bz = curSettings->
points.two.Bz;
275
276 f32 ABx = Bx - Ax;
277 f32 ABz = Bz - Az;
278
283
284
285 f32 t = (ABx * (x - Ax) + ABz * (z - Az)) / (
SQ(ABx) +
SQ(ABz));
286 f32 Px = Ax + t * ABx;
287 f32 Pz = Az + t * ABz;
288
289
290 f32 orthoX = x - Px;
291 f32 orthoZ = z - Pz;
292
293
294 if (t < 0.0f) {
295 Px = Ax;
296 Pz = Az;
297 } else if (t > 1.0f) {
298 Px = Bx;
299 Pz = Bz;
300 }
301 if (!curSettings->
flag) {
302 Px += orthoX;
303 Pz += orthoZ;
304 }
305
309
310 if (changingZone) {
311 if (*interpAlpha != 1.0f) {
312 prevSettings = *prevSettingsPtr;
316 && (prevSettings->
type == curSettings->
type)
320 && (prevSettings->
flag != curSettings->
flag)
321 ) {
322 *interpAlpha = 1.0f;
323 }
324 }
325 }
326 }
327 break;
329 {
330 f32 Ax = curSettings->
points.two.Ax;
331 f32 Az = curSettings->
points.two.Az;
332 f32 Bx = curSettings->
points.two.Bx;
333 f32 Bz = curSettings->
points.two.Bz;
334
335 f32 ABx = Bx - Ax;
336 f32 ABz = Bz - Az;
337 f32 camRadius =
sqrtf(
SQ(ABx) +
SQ(ABz));
338 f32 curRadius, dx, dz;
339
341
342 dx = x - Ax;
343 dz = z - Az;
345 } else {
346 dx = Ax - x;
347 dz = Az - z;
349 }
353
354 if (curSettings->
flag) {
355
356 dx = x - Ax;
357 dz = z - Az;
359
360 if (curRadius != 0.0f) {
361
362 curRig->
targetPos.
x = Ax + dx * (camRadius / curRadius);
364 curRig->
targetPos.
z = Az + dz * (camRadius / curRadius);
365 }
366 } else {
370 }
371
372 if (changingZone) {
373 if (*interpAlpha != 1.0f) {
374 prevSettings = *prevSettingsPtr;
378 && (prevSettings->
type == curSettings->
type)
382 && (prevSettings->
flag != curSettings->
flag)
383 && (prevSettings->
points.two.Ax == curSettings->
points.two.Ax)
384 && (prevSettings->
points.two.Az == curSettings->
points.two.Az)
385 ) {
386 *interpAlpha = 1.0f;
387 }
388 }
389 }
390 }
391 break;
393 {
394 f32 Ax = curSettings->
points.three.Ax;
395 f32 Az = curSettings->
points.three.Az;
396 f32 Bx = curSettings->
points.three.Bx;
397 f32 Bz = curSettings->
points.three.Bz;
398 f32 Cx = curSettings->
points.three.Cx;
399 f32 Cz = curSettings->
points.three.Cz;
400
401 if (!curSettings->
flag) {
402 f32 Tx, Tz;
403
404 if (Ax == Bx && Az == Bz) {
405 Ax = Cx;
406 Az = Cz;
407 }
408
409 f32 ABx = Bx - Ax;
410 f32 BAz = Az - Bz;
411 f32 CBx = Bx - Cx;
412 f32 CBz = Bz - Cz;
413
414 if (CBx == 0.0f) {
415 f32 Q = CBx * ABx / CBz + BAz;
416 f32 V = (x - Bx) - (z - Bz) * CBx / CBz;
417
418 Tx = x - BAz * V / Q;
419 Tz = z + ABx * V / Q;
420 } else {
421 f32 Q = BAz * CBz / CBx + ABx;
422 f32 V = (z - Bz) - (x - Bx) * CBz / CBx;
423
424 Tx = x + BAz * V / Q;
425 Tz = z + ABx * V / Q;
426 }
427
431
432 if (changingMap) {
433 dx = Bx - Ax;
434 dz = Bz - Az;
439 }
440 } else {
441 if (changingMap) {
442 dx = Bx - Ax;
443 dz = Bz - Az;
451 } else if (changingZone) {
455 }
456 }
458 }
459 break;
461 {
462
463 f32 Ax = curSettings->
points.three.Ax;
464 f32 Az = curSettings->
points.three.Az;
465 f32 Bx = curSettings->
points.three.Bx;
466 f32 Bz = curSettings->
points.three.Bz;
467 f32 Cx = curSettings->
points.three.Cx;
468 f32 Cz = curSettings->
points.three.Cz;
469
470 if (!curSettings->
flag) {
471 f32 CBx = Bx - Cx;
472 f32 CBz = Bz - Cz;
473 f32 dist2 =
SQ(CBx) +
SQ(CBz);
474 dist2 = (CBx * (x - Cx) + CBz * (z - Cz)) / dist2;
475 f32 Px = Cx + dist2 * CBx;
476 f32 Pz = Cz + dist2 * CBz;
477
481
483 dx = Px - Ax;
484 dz = Pz - Az;
486 } else {
487 dx = Ax - Px;
488 dz = Az - Pz;
490 }
494 } else {
495 if (changingMap) {
497 dx = Bx - Ax;
498 dz = Bz - Az;
500 } else {
501 dx = Ax - Bx;
502 dz = Az - Bz;
504 }
511 } else if (changingZone) {
515 }
516 }
518 }
519 break;
520 }
521
522 if (changingZone
531 ) {
532 *interpAlpha = 1.0f;
533 }
534 }
535
537 if (changingZone) {
541 }
545 }
546}
@ CAM_CONTROL_FIXED_ORIENTATION
@ CAM_CONTROL_FIXED_POS_AND_ORIENTATION
@ CAM_CONTROL_CONSTRAIN_TO_LINE
@ CAM_CONTROL_FOLLOW_PLAYER
@ CAM_CONTROL_CONSTAIN_BETWEEN_POINTS
@ CAM_CONTROL_LOOK_AT_POINT
@ CAM_CONTROL_LOOK_AT_POINT_CONSTAIN_TO_LINE