public JToken GetPakMeshData([Url] string mapName, int bodyPart, int model, int lod) { var bsp = BspController.GetBspFile(Request, mapName); return(GetMeshData(bsp.PakFile, bodyPart, model, lod)); }
private JToken GetIndex(IResourceProvider provider, string filePath, string mapName = null) { StudioModelFile mdl; using (var mdlStream = provider.OpenFile(filePath)) { mdl = new StudioModelFile(mdlStream); } var parts = new JArray(); for (var bodyPartIndex = 0; bodyPartIndex < mdl.BodyPartCount; ++bodyPartIndex) { var models = new JArray(); var modelIndex = 0; foreach (var model in mdl.GetModels(bodyPartIndex)) { var meshes = new JArray(); foreach (var mesh in mdl.GetMeshes(model.MeshIndex, model.NumMeshes)) { meshes.Add(new JObject { { "material", mesh.Material }, { "center", mesh.Center.ToJson() } }); } var meshDataAction = mapName == null?nameof(GetVpkMeshData) : nameof(GetPakMeshData); models.Add(new JObject { { "name", model.Name }, { "radius", model.BoundingRadius }, { "meshDataUrl", GetActionUrl(meshDataAction, ResourcePath(filePath), Replace("mapName", mapName), Replace("bodyPart", bodyPartIndex), Replace("model", modelIndex), Replace("lod", 0)) }, { "meshes", meshes } }); ++modelIndex; } parts.Add(new JObject { { "name", mdl.GetBodyPartName(bodyPartIndex) }, { "models", models } }); } var materials = new JArray(); for (var i = 0; i < mdl.NumTextures; ++i) { var vmtPath = provider is ValveBspFile.PakFileLump ? mdl.GetMaterialName(i, provider, Resources) : mdl.GetMaterialName(i, provider); if (!vmtPath.Contains("/")) { var mdlDir = Path.GetDirectoryName(filePath); vmtPath = Path.Combine(mdlDir, vmtPath).Replace('\\', '/'); } var vmt = mapName == null ? VmtUtils.OpenVmt(vmtPath) : VmtUtils.OpenVmt(BspController.GetBspFile(Request, mapName), vmtPath); materials.Add(vmt == null ? null : VmtUtils.SerializeVmt(Request, vmt, vmtPath)); } return(new JObject { { "materials", materials }, { "bodyParts", parts } }); }
public void GetPng([Url] string mapName, int mipmap = 0, int frame = -1, int face = -1, int zslice = 0) { var bsp = BspController.GetBspFile(Request, mapName); GetPng(bsp.PakFile, FilePath, mipmap, frame, face, zslice); }
public JToken GetIndex([Url] string mapName) { var bsp = BspController.GetBspFile(Request, mapName); return(GetIndex(bsp.PakFile, FilePath, mapName)); }
public JObject GetJson([Url] string mapName) { var bsp = BspController.GetBspFile(Request, mapName); return(GetJson(bsp.PakFile, FilePath, mapName)); }