static bool Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath) { STRG strg; FILE* fp = hecl::Fopen(inPath.getAbsolutePath().c_str(), _S("rb")); strg.fromYAMLFile(fp); fclose(fp); athena::io::FileWriter ws(outPath.getAbsolutePath()); strg.write(ws); return true; }
bool DCLN::Cook(const hecl::ProjectPath& outPath, const std::vector<Mesh>& meshes) { DCLN dcln; dcln.colCount = atUint32(meshes.size()); for (const Mesh& mesh : meshes) { dcln.collision.emplace_back(); Collision& colOut = dcln.collision.back(); DeafBabeBuildFromBlender(colOut, mesh); colOut.root = std::move(*OBBTreeBuilder::buildCol<Collision::Node>(mesh)); colOut.memSize = atUint32(colOut.root.getMemoryUsage()); } #if DCLN_DUMP_OBB hecl::blender::Connection& conn = hecl::blender::SharedBlenderToken.getBlenderConnection(); conn.createBlend(outPath.getWithExtension(_SYS_STR(".blend")), hecl::blender::BlendType::ColMesh); dcln.sendToBlender(conn, "BLAH"); conn.saveBlend(); #endif athena::io::FileWriter w(outPath.getAbsolutePath()); dcln.write(w); int64_t rem = w.position() % 32; if (rem) for (int64_t i = 0; i < 32 - rem; ++i) w.writeUByte(0xff); return true; }
Space::Class Resource::DeduceDefaultSpaceClass(const hecl::ProjectPath& path) { athena::io::FileReader r(path.getAbsolutePath(), 32*1024, false); if (r.hasError()) return Space::Class::None; return Space::Class::None; }
static bool Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { STRG strg; strg.read(rs); FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb")); strg.toYAMLFile(fp); fclose(fp); return true; }
bool Cook(const hecl::blender::MapArea& mapaIn, const hecl::ProjectPath& out) { if (mapaIn.verts.size() >= 256) { Log.report(logvisor::Error, _SYS_STR("MAPA %s vertex range exceeded [%d/%d]"), out.getRelativePath().data(), mapaIn.verts.size(), 255); return false; } MAPAType mapa; mapa.magic = 0xDEADD00D; mapa.version = MAPAType::Version(); zeus::CAABox aabb; for (const hecl::blender::Vector3f& vert : mapaIn.verts) aabb.accumulateBounds(vert.val); mapa.header = std::make_unique<typename MAPAType::Header>(); typename MAPAType::Header& header = static_cast<typename MAPAType::Header&>(*mapa.header); header.unknown1 = 0; header.mapVisMode = mapaIn.visType.val; header.boundingBox[0] = aabb.min; header.boundingBox[1] = aabb.max; header.moCount = mapaIn.pois.size(); header.vtxCount = mapaIn.verts.size(); header.surfCount = mapaIn.surfaces.size(); mapa.mappableObjects.reserve(mapaIn.pois.size()); for (const hecl::blender::MapArea::POI& poi : mapaIn.pois) { mapa.mappableObjects.push_back(std::make_unique<typename MAPAType::MappableObject>()); typename MAPAType::MappableObject& mobj = static_cast<typename MAPAType::MappableObject&>(*mapa.mappableObjects.back()); mobj.type = MAPA::IMappableObject::Type(poi.type); mobj.visMode = poi.visMode; mobj.sclyId = poi.objid; mobj.transformMtx[0] = poi.xf.val[0]; mobj.transformMtx[1] = poi.xf.val[1]; mobj.transformMtx[2] = poi.xf.val[2]; } mapa.vertices.reserve(mapaIn.verts.size()); for (const hecl::blender::Vector3f& vert : mapaIn.verts) mapa.vertices.push_back(vert.val); size_t offsetCur = 0; for (const auto& mo : mapa.mappableObjects) mo->binarySize(offsetCur); offsetCur += mapa.vertices.size() * 12; offsetCur += mapaIn.surfaces.size() * 32; mapa.surfaceHeaders.reserve(mapaIn.surfaces.size()); mapa.surfaces.reserve(mapaIn.surfaces.size()); for (const hecl::blender::MapArea::Surface& surfIn : mapaIn.surfaces) { mapa.surfaceHeaders.emplace_back(); DNAMAPA::MAPA::SurfaceHeader& surfHead = mapa.surfaceHeaders.back(); mapa.surfaces.emplace_back(); DNAMAPA::MAPA::Surface& surf = mapa.surfaces.back(); surf.primitiveCount = 1; surf.primitives.emplace_back(); DNAMAPA::MAPA::Surface::Primitive& prim = surf.primitives.back(); prim.type = GX::TRIANGLESTRIP; prim.indexCount = surfIn.count; prim.indices.reserve(surfIn.count); auto itBegin = mapaIn.indices.begin() + surfIn.start.val; auto itEnd = itBegin + surfIn.count; for (auto it = itBegin; it != itEnd; ++it) prim.indices.push_back(it->val); surf.borderCount = surfIn.borders.size(); surf.borders.reserve(surfIn.borders.size()); for (const auto& borderIn : surfIn.borders) { surf.borders.emplace_back(); DNAMAPA::MAPA::Surface::Border& border = surf.borders.back(); border.indexCount = borderIn.second.val; border.indices.reserve(borderIn.second.val); auto it2Begin = mapaIn.indices.begin() + borderIn.first.val; auto it2End = it2Begin + borderIn.second.val; for (auto it = it2Begin; it != it2End; ++it) border.indices.push_back(it->val); } surfHead.normal = surfIn.normal.val; surfHead.centroid = surfIn.centerOfMass; surfHead.polyOff = offsetCur; offsetCur += 4; prim.binarySize(offsetCur); surfHead.edgeOff = offsetCur; offsetCur += 4; for (const auto& border : surf.borders) border.binarySize(offsetCur); } athena::io::FileWriter f(out.getAbsolutePath()); mapa.write(f); int64_t rem = f.position() % 32; if (rem) for (int64_t i = 0; i < 32 - rem; ++i) f.writeBytes((atInt8*)"\xff", 1); return true; }