| 1460 |
1460 |
|
| 1461 |
1461 |
}
|
| 1462 |
1462 |
|
|
1463 |
float open_file_value;
|
| 1463 |
1464 |
|
|
1465 |
void open_file_read(void) {
|
|
1466 |
if (open_file_value)
|
|
1467 |
return;
|
|
1468 |
else
|
|
1469 |
open_file_value = fopen("test_write", FILE_READ);
|
|
1470 |
}
|
|
1471 |
|
|
1472 |
void open_file_write(void) {
|
|
1473 |
if (open_file_value)
|
|
1474 |
return;
|
|
1475 |
else
|
|
1476 |
open_file_value = fopen("test_write", FILE_WRITE);
|
|
1477 |
}
|
|
1478 |
|
|
1479 |
void close_file(void) {
|
|
1480 |
if (open_file_value) {
|
|
1481 |
fclose(open_file_value);
|
|
1482 |
open_file_value = 0;
|
|
1483 |
}
|
|
1484 |
}
|
|
1485 |
|
|
1486 |
vector origin_next, angle_next;
|
|
1487 |
float time_next, playback_finished;
|
| 1464 |
1488 |
// following vectors must be global to allow seamless switching between camera modes
|
| 1465 |
1489 |
vector camera_offset, current_camera_offset, mouse_angles, current_angles, current_origin, current_position;
|
| 1466 |
1490 |
void CSQC_Demo_Camera()
|
| 1467 |
1491 |
{
|
|
1492 |
if (autocvar_camera_playback) {
|
|
1493 |
open_file_read();
|
|
1494 |
string s, s2;
|
|
1495 |
|
|
1496 |
float t, n, l;
|
|
1497 |
|
|
1498 |
if (time >= time_next) {
|
|
1499 |
R_SetView(VF_ANGLES, angle_next);
|
|
1500 |
R_SetView(VF_ORIGIN, origin_next);
|
|
1501 |
|
|
1502 |
s = fgets(open_file_value);
|
|
1503 |
|
|
1504 |
if(s == "") {
|
|
1505 |
print("^1file closed\n");
|
|
1506 |
close_file();
|
|
1507 |
autocvar_camera_playback = 0;
|
|
1508 |
return;
|
|
1509 |
}
|
|
1510 |
|
|
1511 |
s2 = substring(s, 0, 2);
|
|
1512 |
|
|
1513 |
if(s2 == "//")
|
|
1514 |
print("Comment\n");
|
|
1515 |
else if(s2 == "##")
|
|
1516 |
print("Do stuff\n");
|
|
1517 |
else {
|
|
1518 |
n = tokenizebyseparator(s, ",");
|
|
1519 |
|
|
1520 |
if(n != 3) {
|
|
1521 |
print("^1Error: ", s, "\n");
|
|
1522 |
return;
|
|
1523 |
}
|
|
1524 |
|
|
1525 |
time_next = stof(argv(0));
|
|
1526 |
|
|
1527 |
origin_next = stov(argv(1));
|
|
1528 |
angle_next = stov(argv(2));
|
|
1529 |
}
|
|
1530 |
} else {
|
|
1531 |
R_SetView(VF_ANGLES, angle_next);
|
|
1532 |
R_SetView(VF_ORIGIN, origin_next);
|
|
1533 |
}
|
|
1534 |
} else {
|
| 1468 |
1535 |
float speed, attenuation, dimensions;
|
| 1469 |
1536 |
vector tmp, delta;
|
| 1470 |
1537 |
|
| ... | ... | |
| 1605 |
1672 |
|
| 1606 |
1673 |
R_SetView(VF_ANGLES, current_angles);
|
| 1607 |
1674 |
R_SetView(VF_ORIGIN, current_position);
|
| 1608 |
|
}
|
|
1675 |
|
|
1676 |
if (autocvar_camera_record) {
|
|
1677 |
open_file_write();
|
|
1678 |
fputs(open_file_value, strcat(ftos(time), ",", vtos(current_position), ",", vtos(current_angles), "\n"));
|
|
1679 |
} else {
|
|
1680 |
close_file();
|
|
1681 |
}
|
|
1682 |
}
|
|
1683 |
}
|