MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / LoadObjects

Function LoadObjects

TombEngine/Specific/level.cpp:283–583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283void LoadObjects()
284{
285 Objects.Initialize();
286 Statics.Initialize();
287
288 int meshCount = ReadCount();
289 TENLog("Mesh count: " + std::to_string(meshCount), LogLevel::Info);
290
291 g_Level.Meshes.reserve(meshCount);
292 for (int i = 0; i < meshCount; i++)
293 {
294 auto mesh = MESH{};
295
296 mesh.hidden = ReadBool();
297 mesh.lightMode = (LightMode)ReadUInt8();
298
299 mesh.sphere.Center.x = ReadFloat();
300 mesh.sphere.Center.y = ReadFloat();
301 mesh.sphere.Center.z = ReadFloat();
302 mesh.sphere.Radius = ReadFloat();
303
304 int vertexCount = ReadCount(CUBE(1024));
305
306 mesh.positions.resize(vertexCount);
307 ReadBytes(mesh.positions.data(), 12 * vertexCount);
308
309 mesh.colors.resize(vertexCount);
310 ReadBytes(mesh.colors.data(), 12 * vertexCount);
311
312 mesh.effects.resize(vertexCount);
313 ReadBytes(mesh.effects.data(), 12 * vertexCount);
314
315 mesh.boneIndices.resize(vertexCount);
316 mesh.boneWeights.resize(vertexCount);
317 ReadBytes(mesh.boneIndices.data(), sizeof(unsigned char) * 4 * vertexCount);
318 ReadBytes(mesh.boneWeights.data(), sizeof(unsigned char) * 4 * vertexCount);
319
320 int bucketCount = ReadCount();
321 mesh.buckets.reserve(bucketCount);
322 for (int j = 0; j < bucketCount; j++)
323 {
324 auto bucket = BUCKET{};
325
326 bucket.texture = ReadInt32();
327 bucket.blendMode = (BlendMode)ReadUInt8();
328 bucket.materialIndex = ReadInt32();
329 bucket.animated = ReadBool();
330
331 bucket.numQuads = 0;
332 bucket.numTriangles = 0;
333
334 int polyCount = ReadCount(CUBE(1024));
335 bucket.polygons.reserve(polyCount);
336 for (int k = 0; k < polyCount; k++)
337 {
338 auto poly = POLYGON{};
339
340 poly.shape = ReadInt32();

Callers 1

LoadLevelFunction · 0.85

Calls 15

ReadCountFunction · 0.85
TENLogFunction · 0.85
to_stringFunction · 0.85
ReadBoolFunction · 0.85
ReadUInt8Function · 0.85
ReadFloatFunction · 0.85
ReadBytesFunction · 0.85
ReadInt32Function · 0.85
ReadVector3Function · 0.85
ReadVector2Function · 0.85
ReadVector4Function · 0.85
InitializeObjectsFunction · 0.85

Tested by

no test coverage detected