MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / LoadGEO

Method LoadGEO

src/Loaders/nfs2_loader.cpp:30–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29template<>
30std::vector<CarModel> NFS2<PC>::LoadGEO(const std::string &geo_path, std::map<unsigned int, Texture> car_textures, std::map<std::string, uint32_t> remapped_texture_ids) {
31 // Mike Thompson CarEd disasm parts table for NFS2 Cars
32 std::string PC_PART_NAMES[32]{
33 "High Additional Body Part",
34 "High Main Body Part",
35 "High Ground Part",
36 "High Front Part",
37 "High Back Part",
38 "High Left Side Part",
39 "High Right Side Part",
40 "High Additional Left Side Part",
41 "High Additional Right Side Part",
42 "High Spoiler Part",
43 "High Additional Part",
44 "High Backlights",
45 "High Front Right Wheel",
46 "High Front Right Wheel Part",
47 "High Front Left Wheel",
48 "High Front Left Wheel Part",
49 "High Rear Right Wheel",
50 "High Rear Right Wheel Part",
51 "High Rear Left Wheel",
52 "High Rear Left Wheel Part",
53 "Medium Additional Body Part",
54 "Medium Main Body Part",
55 "Medium Ground Part",
56 "Low Wheel Part",
57 "Low Main Part",
58 "Low Side Part",
59 "Reserved",
60 "Reserved",
61 "Reserved",
62 "Reserved",
63 "Reserved",
64 "Reserved",
65 };
66
67 float carScaleFactor = 2000.f;
68 glm::quat rotationMatrix = glm::normalize(glm::quat(glm::vec3(0, 0, 0))); // All Vertices are stored so that the model is rotated 90 degs on X. Remove this at Vert load time.
69
70 LOG(INFO) << "Parsing PC GEO File located at " << geo_path;
71 std::vector<CarModel> car_meshes;
72 ifstream geo(geo_path, ios::in | ios::binary);
73
74 auto *geoFileHeader = new PC::GEO::HEADER();
75 if (geo.read((char *) geoFileHeader, sizeof(PC::GEO::HEADER)).gcount() != sizeof(PC::GEO::HEADER)) {
76 LOG(WARNING) << "Couldn't open file/truncated." << std::endl;
77 delete geoFileHeader;
78 return car_meshes;
79 }
80
81 uint32_t part_Idx = -1;
82
83 while (true) {
84 streamoff start = geo.tellg();
85
86 auto *geoBlockHeader = new PC::GEO::BLOCK_HEADER();
87 while (geoBlockHeader->nVerts == 0) {

Callers

nothing calls this directly

Calls 4

calculateQuadNormalFunction · 0.85
pointToVecFunction · 0.85
CarModelClass · 0.85
nfsUvGenerateFunction · 0.85

Tested by

no test coverage detected