public static Vector3 GetXNAPosition(Q3BSPEntity entity) { if (entity == null) { return(Vector3.Zero); } string origin = (string)entity.Entries["origin"]; string[] xzy = null; if (origin != null) { xzy = origin.Split(' '); } if (xzy == null || xzy.Length != 3) { return(Vector3.Zero); } Vector3 position = Vector3.Zero; try { position = new Vector3(float.Parse(xzy[0]), float.Parse(xzy[2]), -float.Parse(xzy[1])) * 0.25f; } catch (Exception) { } return(position); }
public bool LoadEntities(string entityString) { Regex rx = new Regex("{([^}]*)}", RegexOptions.Compiled | RegexOptions.Multiline); MatchCollection matches = rx.Matches(entityString); if (0 < matches.Count) { entities = new Q3BSPEntity[matches.Count]; for (int i = 0; i < matches.Count; i++) { entities[i] = new Q3BSPEntity(); entities[i].ParseString(matches[i].Groups[1].Value); } return(true); } return(false); }