| 209 | } |
| 210 | |
| 211 | void loadVueFile(Allocator* vueList, char* transformName, TFE_Parser* parser) |
| 212 | { |
| 213 | size_t bufferPos = 0; |
| 214 | if (!strcasecmp(transformName, "camera")) |
| 215 | { |
| 216 | // TFE: allocate a VFRAME_FIRST for camera transforms, same as with ordinary transforms |
| 217 | VueFrame* frame = (VueFrame*)allocator_newItem(vueList); |
| 218 | if (!frame) |
| 219 | return; |
| 220 | frame->flags = VFRAME_FIRST; |
| 221 | |
| 222 | while (1) |
| 223 | { |
| 224 | const char* line = parser->readLine(bufferPos); |
| 225 | if (!line) { break; } |
| 226 | |
| 227 | f32 x1, z1, y1, x2, z2, y2, r, lens; |
| 228 | if (sscanf(line, "camera %f %f %f %f %f %f %f %f", &x1, &z1, &y1, &x2, &z2, &y2, &r, &lens) == 8) |
| 229 | { |
| 230 | y1 = -y1; |
| 231 | y2 = -y2; |
| 232 | VueFrame* frame = (VueFrame*)allocator_newItem(vueList); |
| 233 | if (!frame) |
| 234 | return; |
| 235 | frame->offset.x = floatToFixed16(x1); |
| 236 | frame->offset.y = floatToFixed16(y1); |
| 237 | frame->offset.z = floatToFixed16(z1); |
| 238 | frame->yaw = vec2ToAngle(floatToFixed16(x2 - x1), floatToFixed16(z2 - z1)); |
| 239 | |
| 240 | // TFE: calculate pitch (this was not done in vanilla) |
| 241 | f32 dx = x2 - x1; |
| 242 | f32 dz = z2 - z1; |
| 243 | f64 xzVec = sqrt(dx * dx + dz * dz); |
| 244 | frame->pitch = vec2ToAngle(floatToFixed16(y1 - y2), floatToFixed16((f32)xzVec)); |
| 245 | frame->roll = angle14_32(r * 16383.0f / 360.0f); |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | else |
| 250 | { |
| 251 | // Matrix 0 |
| 252 | fixed16_16 mtx0[9]; |
| 253 | mtx0[0] = ONE_16; |
| 254 | mtx0[1] = 0; |
| 255 | mtx0[2] = 0; |
| 256 | |
| 257 | mtx0[3] = 0; |
| 258 | mtx0[4] = 1; |
| 259 | mtx0[5] = ONE_16 - 1; |
| 260 | |
| 261 | mtx0[6] = 0; |
| 262 | mtx0[7] = -ONE_16 + 1; |
| 263 | mtx0[8] = 1; |
| 264 | |
| 265 | // Matrix 1 |
| 266 | fixed16_16 mtx1[9]; |
| 267 | mtx1[0] = ONE_16; |
| 268 | mtx1[1] = 0; |
no test coverage detected