#include "CMetroidModelInstance.hpp" #include "Graphics/CCubeSurface.hpp" #include "Streams/IOStreams.hpp" #include namespace metaforce { CMetroidModelInstance::CMetroidModelInstance(std::pair modelHeader, const u8* materialData, std::pair positions, std::pair normals, std::pair colors, std::pair texCoords, std::pair packedTexCoords, std::vector&& surfaces) : x4c_materialData(materialData), x50_surfaces(std::move(surfaces)) { { CMemoryInStream stream{modelHeader.first, modelHeader.second}; x0_visorFlags = stream.Get(); x4_worldXf = stream.Get(); x34_worldAABB = stream.Get(); } { u32 numVertices = positions.second / 12; CMemoryInStream stream{positions.first, positions.second}; for (u32 i = 0; i < numVertices; ++i) { x60_positions.emplace_back(stream.Get()); } } { // Always short normals in MREA u32 numNormals = normals.second / 6; CMemoryInStream stream{normals.first, normals.second}; for (u32 i = 0; i < numNormals; ++i) { x64_normals.emplace_back(static_cast(stream.ReadShort()) / 16384.f, static_cast(stream.ReadShort()) / 16384.f, static_cast(stream.ReadShort()) / 16384.f); } } { u32 numColors = colors.second / 4; CMemoryInStream stream{colors.first, colors.second}; for (u32 i = 0; i < numColors; ++i) { x68_colors.emplace_back(zeus::CColor(stream.ReadUint32())); } } { u32 numTexCoords = texCoords.second / 8; CMemoryInStream stream{texCoords.first, texCoords.second}; for (u32 i = 0; i < numTexCoords; ++i) { x6c_texCoords.emplace_back(stream.Get()); } } { u32 numPackedTexCoords = packedTexCoords.second / 4; CMemoryInStream stream{packedTexCoords.first, packedTexCoords.second}; for (u32 i = 0; i < numPackedTexCoords; ++i) { x70_packedTexCoords.emplace_back(static_cast(stream.ReadShort()) / 32768.f, static_cast(stream.ReadShort()) / 32768.f); } } } } // namespace metaforce