private void ProcessNewSectionStart(string line) { try { currentSection = (IPLSection)Enum.Parse(typeof(IPLSection), line, true); } catch { Log.Warning("Unknow IPL section {0} in \"{1}\"", line.ToUpper(), FilePath); currentSection = IPLSection.Unknow; } }
private void ProcessNewSectionStart(string line) { if (line.StartsWith("inst")) { currentSection = IPLSection.INST; } else if (line.StartsWith("cull")) { currentSection = IPLSection.CULL; } else if (line.StartsWith("pick")) { currentSection = IPLSection.PICK; } }
protected override void ParseLine(string line) { ItemPlacement obj; switch (currentSection) { case IPLSection.End: ProcessNewSectionStart(line); break; default: if (line.Equals("end", StringComparison.Ordinal)) { currentSection = IPLSection.End; } else if (ProcessSectionItem(line, out obj)) { placements.Add(obj); } break; } }
private SceneItemPlacement ProcessSectionItem(string line) { if (line.StartsWith("end")) { currentSection = IPLSection.END; return(null); } if (currentSection != IPLSection.INST) { return(null); } string[] toks = line.Split(new string[] { ", " }, StringSplitOptions.None); if (toks.Length != INST_REQUIRED_TOKENS[(int)gtaVersion]) { string msg = "Incorrect number of tokens in INST section: " + toks.Length.ToString() + "."; Log.Instance.Print(msg, MessageType.Error); throw new LoadingException(msg); } SceneItemPlacement obj = new SceneItemPlacement(); obj.Id = Int32.Parse(toks[0]); obj.Name = toks[1].ToLower(); obj.Scale = Vector3.One; if (obj.Name.Length == 0) // в GTA VC такое бывает. Если здесь такие объекты не откидывать, упадём при загрузке dff по пустому имени { return(null); } if (gtaVersion == GtaVersion.ViceCity || gtaVersion == GtaVersion.SanAndreas) { // нас не интерисуют внутренние интерьеры, загружаем только внешний мир int interiorId = Int32.Parse(toks[2]); if (interiorId != 0 && interiorId != 13) // Похоже, ребята из RockstarGames суеверны :) { return(null); } } // y and z coords are exchanged because of different coordinate system !!! switch (gtaVersion) { case GtaVersion.III: obj.Position = new Vector3(float.Parse(toks[2]), float.Parse(toks[4]), -float.Parse(toks[3])); obj.Scale = new Vector3(float.Parse(toks[5]), float.Parse(toks[6]), float.Parse(toks[7])); obj.Rotation = new Quaternion(float.Parse(toks[8]), float.Parse(toks[10]), -float.Parse(toks[9]), -float.Parse(toks[11])); break; case GtaVersion.ViceCity: obj.Position = new Vector3(float.Parse(toks[3]), float.Parse(toks[5]), -float.Parse(toks[4])); obj.Scale = new Vector3(float.Parse(toks[6]), float.Parse(toks[7]), float.Parse(toks[8])); obj.Rotation = new Quaternion(float.Parse(toks[9]), float.Parse(toks[11]), -float.Parse(toks[10]), -float.Parse(toks[12])); break; case GtaVersion.SanAndreas: obj.Position = new Vector3(float.Parse(toks[3]), float.Parse(toks[5]), -float.Parse(toks[4])); obj.Rotation = new Quaternion(float.Parse(toks[6]), float.Parse(toks[8]), -float.Parse(toks[7]), -float.Parse(toks[9])); // toks[10] -- LOD -- is temporary ignored break; } return(obj); }
private SceneItemPlacement ProcessSectionItem(string line) { if (line.StartsWith("end")) { currentSection = IPLSection.END; return null; } if (currentSection != IPLSection.INST) return null; string[] toks = line.Split(new string[] { ", " }, StringSplitOptions.None); if (toks.Length != INST_REQUIRED_TOKENS[(int)gtaVersion]) { string msg = "Incorrect number of tokens in INST section: " + toks.Length.ToString() + "."; Log.Instance.Print(msg, MessageType.Error); throw new LoadingException(msg); } SceneItemPlacement obj = new SceneItemPlacement(); obj.Id = Int32.Parse(toks[0]); obj.Name = toks[1].ToLower(); obj.Scale = Vector3.One; if (obj.Name.Length == 0) // в GTA VC такое бывает. Если здесь такие объекты не откидывать, упадём при загрузке dff по пустому имени return null; if (gtaVersion == GtaVersion.ViceCity || gtaVersion == GtaVersion.SanAndreas) { // нас не интерисуют внутренние интерьеры, загружаем только внешний мир int interiorId = Int32.Parse(toks[2]); if (interiorId != 0 && interiorId != 13) // Похоже, ребята из RockstarGames суеверны :) return null; } // y and z coords are exchanged because of different coordinate system !!! switch (gtaVersion) { case GtaVersion.III: obj.Position = new Vector3(float.Parse(toks[2]), float.Parse(toks[4]), -float.Parse(toks[3])); obj.Scale = new Vector3(float.Parse(toks[5]), float.Parse(toks[6]), float.Parse(toks[7])); obj.Rotation = new Quaternion(float.Parse(toks[8]), float.Parse(toks[10]), -float.Parse(toks[9]), -float.Parse(toks[11])); break; case GtaVersion.ViceCity: obj.Position = new Vector3(float.Parse(toks[3]), float.Parse(toks[5]), -float.Parse(toks[4])); obj.Scale = new Vector3(float.Parse(toks[6]), float.Parse(toks[7]), float.Parse(toks[8])); obj.Rotation = new Quaternion(float.Parse(toks[9]), float.Parse(toks[11]), -float.Parse(toks[10]), -float.Parse(toks[12])); break; case GtaVersion.SanAndreas: obj.Position = new Vector3(float.Parse(toks[3]), float.Parse(toks[5]), -float.Parse(toks[4])); obj.Rotation = new Quaternion(float.Parse(toks[6]), float.Parse(toks[8]), -float.Parse(toks[7]), -float.Parse(toks[9])); // toks[10] -- LOD -- is temporary ignored break; } return obj; }
private void ProcessNewSectionStart(string line) { if (line.StartsWith("inst")) currentSection = IPLSection.INST; else if (line.StartsWith("cull")) currentSection = IPLSection.CULL; else if (line.StartsWith("pick")) currentSection = IPLSection.PICK; }