arx-convert
Version:
Converts various Arx Fatalis formats to JSON or YAML and back
150 lines • 7.07 kB
JavaScript
export const VERSION = 0.141_000_002_622_604_37; // 0.141f
// The polygons of Arx are sorted into cells, a 160x160 2D grid on the X and Z axis.
// Arx ignores the 4th vertex of a quad, it always calculates cell coordinates using the first 3 vertices.
// cellX is calculated by averaging the x coordinates of the vertices, dividing that by 100 and rounding it down.
// cellY is calculated the same way as cellX, but using the z coordinates.
// see helpers.ts > getCellCoords
//
// For whatever reason the coords in the table below create polygons, which ends up in an incorrect cell
// according to the cell data in the original level files.
// Probably some precision got lost when Theo Game Maker exported the FTS data.
//
// I've already spent numerous days trying to figure out where the error is originating from,
// so I give up and just put the problematic coordinates into a table below.
//
// There are a very small number of coordinates (that are to be averaged either to produce cellX or cellY)
// which need to be rounded up instead of rounded down:
//
// level 0 -> 9 polygons have coords that needs to be rounded up from the total of 45418 polygons
// level 1 -> 8 / 58963
// level 2 -> 2 / 73791
// level 3 -> 1 / 59442
// level 5 -> 16 / 68710
// level 6 -> 6 / 42111
// level 7 -> 4 / 76875
// level 11 -> 9 / 69815
// level 12 -> 24 / 34660
// level 14 -> 10 / 39387
// level 15 -> 2 / 44616
// level 16 -> 1 / 53367
// level 18 -> 2 / 39098
// level 21 -> 43 / 30594
// level 22 -> 15 / 61953
// level 23 -> 5 / 24519
//
// Some things that I tried, but didn't work:
// - no, the error is much larger, than Number.EPSILON, or Number.EPSILON * 10**5.
// - no, rounding the individual coordinates to 3 or more decimals doesn't solve the issue.
//
// The following fractions we get by calculating (average / 100) % 1
// always need to be rounded up, no matter what coords make up the average:
// 0.9999983723958294,
// 0.9999983723958366,
// 0.9999991861979147,
// 0.9999991861979183
//
// But the following 3 fractions sometimes need to be rounded up and at other times rounded down.
// 0.9999934895833462,
// 0.9999967447916589,
// 0.9999967447916731
//
// level 22 is the best example as it has both cases where the same fraction needs to be rounded
// in both ways within the same level (produced by different coordinates of course).
// prettier-ignore
export const COORDS_THAT_ROUND_UP = [
[2550, 2600, 2649.999_755_859_375],
[2649.999_755_859_375, 2700, 2749.999_755_859_375],
[3949.999_755_859_375, 4000, 4050],
[4294.999_511_718_75, 4299.999_511_718_75, 4305],
[4299.999_511_718_75, 4299.999_511_718_75, 4300],
[4599.999_511_718_75, 4599.999_511_718_75, 4600],
[4899.999_511_718_75, 4900, 4900],
[4995, 4999.999_511_718_75, 5004.999_511_718_75],
[5599.999_023_437_5, 5600, 5600],
[5599.999_511_718_75, 5600, 5600],
[5690.262_695_312_5, 5700, 5709.736_328_125],
[5695.512_695_312_5, 5700, 5704.486_328_125],
[5795, 5799.999_511_718_75, 5804.999_511_718_75],
[5799.999_511_718_75, 5800, 5800],
[5975, 6000, 6024.999_511_718_75],
[6050, 6124.999_511_718_75, 6124.999_511_718_75],
[6057.666_015_625, 6100, 6142.333_007_812_5],
[6090.262_695_312_5, 6100, 6109.736_328_125],
[6174.999_511_718_75, 6174.999_511_718_75, 6250],
[6199.999_511_718_75, 6199.999_511_718_75, 6200.000_488_281_25],
[6349.999_023_437_5, 6400, 6450],
[6439.999_511_718_75, 6525, 6535],
[6450, 6500, 6549.999_511_718_75],
[6450, 6499.999_511_718_75, 6549.999_511_718_75],
[6549.999_023_437_5, 6600.000_976_562_5, 6649.999_023_437_5],
[6599.999_511_718_75, 6599.999_511_718_75, 6600.000_488_281_25],
[6749.997_070_312_5, 6800.001_953_125, 6850],
[6799.999_023_437_5, 6800, 6800],
[6899.999_511_718_75, 6899.999_511_718_75, 6900],
[6999.999_511_718_75, 6999.999_511_718_75, 7000],
[6999.999_511_718_75, 7000, 7000],
[7049.999_511_718_75, 7125, 7125],
[7175, 7175, 7249.999_511_718_75],
[7195.000_488_281_25, 7199.999_511_718_75, 7204.999_511_718_75],
[7280, 7290, 7329.999_023_437_5],
[7294.999_511_718_75, 7299.999_511_718_75, 7305.000_488_281_25],
[7349.999_511_718_75, 7399.999_511_718_75, 7450.000_488_281_25],
[7350.000_488_281_25, 7399.999_511_718_75, 7449.999_511_718_75],
[7399.999_023_437_5, 7400, 7400],
[7399.999_511_718_75, 7399.999_511_718_75, 7400.000_488_281_25],
[7499.999_511_718_75, 7500, 7500],
[7565, 7585, 7649.999_023_437_5],
[7583.333_007_812_5, 7600, 7616.666_015_625],
[7591.866_210_937_5, 7601.762_695_312_5, 7606.370_117_187_5],
[7599.999_023_437_5, 7600, 7600],
[7640.000_976_562_5, 7729.999_023_437_5, 7729.999_023_437_5],
[7650, 7700, 7749.999_023_437_5],
[7775, 7799.999_511_718_75, 7825],
[7799.999_023_437_5, 7800, 7800.000_488_281_25],
[7799.999_511_718_75, 7800, 7800],
[7950, 8024.999_511_718_75, 8025],
[7999.999_511_718_75, 8000, 8000],
[7999.999_511_718_75, 7999.999_511_718_75, 8000],
[8050, 8124.999_511_718_75, 8125],
[8099.995_117_187_5, 8100.000_976_562_5, 8100.002_929_687_5],
[8149.999_511_718_75, 8200, 8250],
[8149.999_511_718_75, 8225, 8225],
[8349.999_023_437_5, 8400, 8449.999_023_437_5],
[8349.999_023_437_5, 8400, 8450],
[8450, 8500, 8549.999_023_437_5],
[8583.249_023_437_5, 8600, 8616.75],
[8649.999_023_437_5, 8700, 8749.999_023_437_5],
[8750, 8800, 8849.999_023_437_5],
[8875, 8875, 8949.999_023_437_5],
[8909.999_023_437_5, 9045, 9045],
[8949.999_023_437_5, 9025, 9025],
[9099.999_023_437_5, 9099.999_023_437_5, 9100],
[9197.515_625, 9199.795_898_437_5, 9202.6875],
[9349.999_023_437_5, 9400, 9449.999_023_437_5],
[9350, 9424.999_023_437_5, 9425],
[9399.999_023_437_5, 9400, 9400],
[9499.999_023_437_5, 9500, 9500],
[9549.999_023_437_5, 9599.999_023_437_5, 9650],
[9650, 9699.999_023_437_5, 9749.999_023_437_5],
[9699.999_023_437_5, 9700, 9700],
[9949.999_023_437_5, 9999.999_023_437_5, 10_050],
[9999.999_023_437_5, 10_000, 10_000],
[10_049.999_023_437_5, 10_100, 10_150],
[10_299.999_023_437_5, 10_300, 10_300],
[10_399.999_023_437_5, 10_400, 10_400],
[10_649.998_046_875, 10_700.002_929_687_5, 10_749.998_046_875],
[10_649.999_023_437_5, 10_699.999_023_437_5, 10_750],
[10_849.995_117_187_5, 10_900.008_789_062_5, 10_949.995_117_187_5],
[11_199.994_140_625, 11_200.001_953_125, 11_200.001_953_125],
[11_299.994_140_625, 11_300.001_953_125, 11_300.001_953_125],
[11_399.994_140_625, 11_400.001_953_125, 11_400.001_953_125],
[11_399.999_023_437_5, 11_400, 11_400],
[11_499.994_140_625, 11_500.001_953_125, 11_500.001_953_125],
[12_049.998_046_875, 12_125, 12_125],
[12_183.333_007_812_5, 12_200, 12_216.666_015_625],
[12_250, 12_299.999_023_437_5, 12_350],
[12_899.999_023_437_5, 12_899.999_023_437_5, 12_900],
[13_199.999_023_437_5, 13_200, 13_200],
[13_839.999_023_437_5, 13_925, 13_935],
];
//# sourceMappingURL=constants.js.map