| 484 | } |
| 485 | |
| 486 | bool LoadCAN(std::string can_path, std::vector<SHARED::CANPT> &cameraAnimations) { |
| 487 | ifstream can(can_path, ios::in | ios::binary); |
| 488 | |
| 489 | if (!can.is_open()) { |
| 490 | return false; |
| 491 | } |
| 492 | |
| 493 | LOG(INFO) << "Loading CAN File located at " << can_path; |
| 494 | |
| 495 | // Get filesize so can check have parsed all bytes |
| 496 | uint16_t size; |
| 497 | uint8_t type, struct3D; |
| 498 | uint16_t animLength, unknown; |
| 499 | |
| 500 | can.read((char *) &size, sizeof(uint16_t)); |
| 501 | can.read((char *) &type, sizeof(uint8_t)); |
| 502 | can.read((char *) &struct3D, sizeof(uint8_t)); |
| 503 | can.read((char *) &animLength, sizeof(uint16_t)); |
| 504 | can.read((char *) &unknown, sizeof(uint16_t)); |
| 505 | |
| 506 | SHARED::CANPT *anim = new SHARED::CANPT[animLength]; |
| 507 | can.read((char *) anim, sizeof(SHARED::CANPT) * animLength); |
| 508 | |
| 509 | for (uint8_t anim_Idx = 0; anim_Idx < animLength; ++anim_Idx) { |
| 510 | cameraAnimations.emplace_back(anim[anim_Idx]); |
| 511 | } |
| 512 | |
| 513 | streamoff readBytes = can.tellg(); |
| 514 | |
| 515 | ASSERT(readBytes == size, "Missing " << size - readBytes << " bytes from loaded CAN file: " << can_path); |
| 516 | |
| 517 | /*ofstream can_out("F:\\NFS3\\nfs3_modern_base_eng\\gamedata\\tracks\\trk000\\tr0000a.can", ios::out | ios::binary); |
| 518 | |
| 519 | if (!can_out.is_open()) { |
| 520 | return false; |
| 521 | } |
| 522 | |
| 523 | std::cout << "Writing CAN File with no rotations" << std::endl; |
| 524 | |
| 525 | can_out.write((char *) &size, sizeof(uint16_t)); |
| 526 | can_out.write((char *) &type, sizeof(uint8_t)); |
| 527 | can_out.write((char *) &struct3D, sizeof(uint8_t)); |
| 528 | can_out.write((char *) &animLength, sizeof(uint16_t)); |
| 529 | can_out.write((char *) &unknown, sizeof(uint16_t)); |
| 530 | |
| 531 | for (uint8_t anim_Idx = 0; anim_Idx < animLength; ++anim_Idx) { |
| 532 | //cameraAnimations[anim_Idx].x = cameraAnimations[animLength-anim_Idx].x; |
| 533 | //cameraAnimations[anim_Idx].y = cameraAnimations[animLength-anim_Idx].y; |
| 534 | //cameraAnimations[anim_Idx].z = cameraAnimations[animLength-anim_Idx].z; |
| 535 | cameraAnimations[anim_Idx].x = cameraAnimations[anim_Idx].x*10; |
| 536 | cameraAnimations[anim_Idx].y = cameraAnimations[anim_Idx].y*10; |
| 537 | cameraAnimations[anim_Idx].z = cameraAnimations[anim_Idx].z*10; |
| 538 | |
| 539 | cameraAnimations[anim_Idx].od1 = cameraAnimations[anim_Idx].od1; |
| 540 | cameraAnimations[anim_Idx].od2 = cameraAnimations[anim_Idx].od2; // OD2 seems to be something more than just rotation, like zoom or some shit |
| 541 | cameraAnimations[anim_Idx].od3 = cameraAnimations[anim_Idx].od3; // OD3 seems to set perspective |
| 542 | cameraAnimations[anim_Idx].od4 = cameraAnimations[anim_Idx].od4; // OD4 similar to OD1, induces wavyness but animation remains |
| 543 | can_out.write((char *) &cameraAnimations[anim_Idx], sizeof(SHARED::CANPT)); |