private bool isShadow(SceneItemPlacement obj)
        {
            SceneItemDefinition ide = null;

            if (!objDefinitions.TryGetValue(obj.Id, out ide))
            {
                return(false);
            }
            return(((ide.Flags & IdeFlags.Shadows) != IdeFlags.None) && obj.Name.Contains("shad"));
        }
예제 #2
0
        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 bool isShadow(SceneItemPlacement obj)
 {
     SceneItemDefinition ide = null;
      if (!objDefinitions.TryGetValue(obj.Id, out ide))
     return false;
      return ((ide.Flags & IdeFlags.Shadows) != IdeFlags.None) && obj.Name.Contains("shad");
 }
        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;
        }