public LIT GetLIT(string name, string folderPath)
        {
            LIT result;

            if (!this.LITs.Contains(name))
            {
                LIT lIT = new LIT();
                lIT.Load(folderPath + name, ClientType.IROSE);
                this.LITs.Add(name, lIT);
                result = lIT;
            }
            else
            {
                result = (LIT)this.LITs[name];
            }
            return(result);
        }
示例#2
0
        public bool Load()
        {
            if (!m_isValid)
            {
                Debug.LogError("Cannot load patch at path " + this.m_assetDir);
                return(false);
            }

            // TODO: add error handling for failure to load the following files
            this.m_HIM = new HIM(this.m_assetDir.Parent.FullName + "/" + this.m_name + ".HIM");
            this.m_TIL = new TIL(this.m_assetDir.Parent.FullName + "/" + this.m_name + ".TIL");
            if (this.m_ZON == null)  // load ZON if it was never passed to the patch constructor
            {
                this.m_ZON = new ZON(this.m_assetDir.Parent.FullName + "/" + this.m_assetDir.Parent.Name + ".ZON");
            }
            this.m_IFO = new IFO(this.m_assetDir.Parent.FullName + "/" + this.m_name + ".IFO");

            //	parent x   :        4	  3		2	  1	   0
            // original dir: .../3ddata/maps/junon/jpt01/30_30
            // desired dir: .../3ddata/junon/LIST_CNST_JPT.ZSC
            char[] trimChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '_' };

            // TODO: use stl's to avoid this mess and be able to load luna/eldeon/oro maps
            string zscPath = m_assetDir.Parent.Name.ToLower().Trim(trimChars);

            if (zscPath.Contains("jd") || zscPath.Contains("jdt") || zscPath.Contains("jg"))
            {
                zscPath = Utils.FixPath(m_3dDataDir + "/" + m_assetDir.Parent.Parent.Name.ToUpper() + "/LIST_CNST_" + zscPath + ".ZSC");                // + m_assetDir.Parent.Name.Trim(trimChars).ToUpper() + ".ZSC");
            }
            else
            {
                zscPath = Utils.FixPath(m_3dDataDir + "/" + m_assetDir.Parent.Parent.Name.ToUpper() + "/LIST_" + "CNST_JPT.ZSC");                // + m_assetDir.Parent.Name.Trim(trimChars).ToUpper() + ".ZSC");
            }
            string litPath = Utils.FixPath(this.m_assetDir.Parent.FullName + "\\" + this.m_name + "\\LIGHTMAP\\BUILDINGLIGHTMAPDATA.LIT");

            groundLight = Utils.FixPath(this.m_assetDir.Parent.FullName + "\\" + this.m_name + "\\" + this.m_name + "_PLANELIGHTINGMAP.DDS");
            m_ZSC_Cnst  = new ZSC(zscPath);
            m_ZSC_Deco  = new ZSC(zscPath.ToLower().Replace("cnst", "deco"));
            m_LIT_Cnst  = new LIT(litPath);
            m_LIT_Deco  = new LIT(litPath.Replace("building", "object"));
            // TODO: add any new file loads here

            edgeVertexLookup = new Dictionary <string, List <int> >();

            return(true);
        }
示例#3
0
        public void LITReader(string file)
        {
            LITs   = default;
            _IO    = File.OpenReader(file + ".lit", true);
            header = _IO.ReadHeader();
            if (header.Signature != 0x4354494C || header.InnerSignature != 0x2 ||
                header.SectionSignature != 0x2)
            {
                return;
            }

            LITs = _IO.RCPE <CountPointer <LIT> >();
            if (LITs.C < 1)
            {
                _IO.C(); LITs.C = -1; return;
            }

            _IO.P = LITs.O;
            for (i = 0; i < LITs.C; i++)
            {
                LITs[i] = _IO.RCPX <LIT>();
                if ((LITs[i].C > 0 || LITs[i].O == 0) && !_IO.IsX)
                {
                    _IO.C(); LITs.C = -1; return;
                }

                /*{
                 *  _IO.Format = Header.Format = Format.X;
                 *  _IO.Offset = Header.Length;
                 *  _IO.Position = LITs.Offset;
                 *  LITs[i] = _IO.ReadCountPointerX<LIT>();
                 * }
                 * if (_IO.IsX) IO.ReadInt64();*/
            }

            for (i = 0; i < LITs.C; i++)
            {
                _IO.P = LITs[i].O;
                for (i0 = 0; i0 < LITs[i].C; i0++)
                {
                    ref LIT lit = ref LITs.E[i].E[i0];
                    lit.Id    = (Id   )_IO.RI32E();
                    lit.Flags = (Flags)_IO.RI32E();
                    lit.Type  = (Type )_IO.RI32E();
                    if (_IO.IsX)
                    {
                        _IO.RI64(); _IO.RI64(); _IO.RI64();
                    }
                    lit.Ambient.X   = _IO.RF32E();
                    lit.Ambient.Y   = _IO.RF32E();
                    lit.Ambient.Z   = _IO.RF32E();
                    lit.Ambient.W   = _IO.RF32E();
                    lit.Diffuse.X   = _IO.RF32E();
                    lit.Diffuse.Y   = _IO.RF32E();
                    lit.Diffuse.Z   = _IO.RF32E();
                    lit.Diffuse.W   = _IO.RF32E();
                    lit.Specular.X  = _IO.RF32E();
                    lit.Specular.Y  = _IO.RF32E();
                    lit.Specular.Z  = _IO.RF32E();
                    lit.Specular.W  = _IO.RF32E();
                    lit.Position.X  = _IO.RF32E();
                    lit.Position.Y  = _IO.RF32E();
                    lit.Position.Z  = _IO.RF32E();
                    lit.ToneCurve.X = _IO.RF32E();
                    lit.ToneCurve.Y = _IO.RF32E();
                    lit.ToneCurve.Z = _IO.RF32E();
                    if (_IO.IsX)
                    {
                        _IO.RI64(); _IO.RI64(); _IO.RI64();
                        _IO.RI64(); _IO.RI64(); _IO.RI32();
                    }
                }
            }
示例#4
0
        public void LITReader(string file)
        {
            IsX  = false;
            LITs = default;
            byte[] litData = File.ReadAllBytes(file + ".lit");
            Struct _LITC   = litData.RSt(); litData = null;

            if (_LITC.Header.Signature != 0x4354494C)
            {
                return;
            }

            s      = File.OpenReader(_LITC.Data);
            s.IsBE = _LITC.Header.UseBigEndian;

            s.RI32();
            LITs = s.RCPE <LightStruct>();
            if (LITs.C < 1)
            {
                s.C(); LITs.C = -1; return;
            }

            s.PI64 = LITs.O - _LITC.Header.Length;
            if (s.RI32() != 0)
            {
                s.PI64 = LITs.O - _LITC.Header.Length;
                for (i = 0; i < LITs.C; i++)
                {
                    LITs.E[i] = new LightStruct
                    {
                        C0 = s.RI32E(), O0 = s.RI32E()
                    }
                }
                ;

                for (i = 0; i < LITs.C; i++)
                {
                    s.PI64 = LITs.E[i].O0 - _LITC.Header.Length;
                    for (i0 = 0; i0 < LITs.E[i].C0; i0++)
                    {
                        ref LIT lit = ref LITs.E[i].E0[i0];
                        lit.Id          = s.RI32E();
                        lit.Flags       = (Flags)s.RI32E();
                        lit.Type        = (Type )s.RI32E();
                        lit.Ambient.X   = s.RF32E();
                        lit.Ambient.Y   = s.RF32E();
                        lit.Ambient.Z   = s.RF32E();
                        lit.Ambient.W   = s.RF32E();
                        lit.Diffuse.X   = s.RF32E();
                        lit.Diffuse.Y   = s.RF32E();
                        lit.Diffuse.Z   = s.RF32E();
                        lit.Diffuse.W   = s.RF32E();
                        lit.Specular.X  = s.RF32E();
                        lit.Specular.Y  = s.RF32E();
                        lit.Specular.Z  = s.RF32E();
                        lit.Specular.W  = s.RF32E();
                        lit.Position.X  = s.RF32E();
                        lit.Position.Y  = s.RF32E();
                        lit.Position.Z  = s.RF32E();
                        lit.ToneCurve.X = s.RF32E();
                        lit.ToneCurve.Y = s.RF32E();
                        lit.ToneCurve.Z = s.RF32E();
                    }
                }
            }
            else
            {
                IsX    = true;
                s.PI64 = LITs.O;
                for (i = 0; i < LITs.C; i++)
                {
                    LITs.E[i] = new LightStruct
                    {
                        C0 = s.RI32E(), C1 = s.RI32E(), O0 = (int)s.RI64E(), O1 = (int)s.RI64E()
                    }
                }
                ;

                for (i = 0; i < LITs.C; i++)
                {
                    s.P = LITs.E[i].O0;
                    for (i0 = 0; i0 < LITs.E[i].C0; i0++)
                    {
                        ref LIT lit = ref LITs.E[i].E0[i0];
                        lit.Id    = s.RI32E();
                        lit.Flags = (Flags)s.RI32E();
                        lit.Type  = (Type )s.RI32E();
                        s.RI32();
                        long off = s.RI64();
                        lit.HasStr      = s.RI64() != 0;
                        lit.Unk10       = s.RI32();
                        lit.Ambient.X   = s.RF32E();
                        lit.Ambient.Y   = s.RF32E();
                        lit.Ambient.Z   = s.RF32E();
                        lit.Ambient.W   = s.RF32E();
                        lit.Diffuse.X   = s.RF32E();
                        lit.Diffuse.Y   = s.RF32E();
                        lit.Diffuse.Z   = s.RF32E();
                        lit.Diffuse.W   = s.RF32E();
                        lit.Specular.X  = s.RF32E();
                        lit.Specular.Y  = s.RF32E();
                        lit.Specular.Z  = s.RF32E();
                        lit.Specular.W  = s.RF32E();
                        lit.Position.X  = s.RF32E();
                        lit.Position.Y  = s.RF32E();
                        lit.Position.Z  = s.RF32E();
                        lit.Unk01       = s.RF32();
                        lit.Unk02       = s.RF32();
                        lit.Unk03       = s.RF32();
                        lit.Unk04       = s.RF32();
                        lit.Unk05.X     = s.RF32();
                        lit.Unk05.Y     = s.RF32();
                        lit.Unk05.Z     = s.RF32();
                        lit.ToneCurve.X = s.RF32E();
                        lit.ToneCurve.Y = s.RF32E();
                        lit.ToneCurve.Z = s.RF32E();
                        lit.Unk         = s.RF32();
                        lit.Unk06       = s.RF32();
                        lit.Unk07       = s.RF32();
                        lit.Unk08       = s.RF32();

                        lit.Str = off > 0 ? s.RaO(off).ToSJIS() : "";
                    }

                    s.P = LITs.E[i].O1;
                    for (i0 = 0; i0 < LITs.E[i].C1; i0++)
                    {
                        ref LITX lit = ref LITs.E[i].E1[i0];
                        lit.C = s.RI32E();
                        s.RI32E();
                        lit.O = (int)s.RI64E();
                    }

                    for (i0 = 0; i0 < LITs.E[i].C1; i0++)
                    {
                        ref LITX lit = ref LITs.E[i].E1[i0];
                        ref      KeyValuePair <int, int>[] data = ref lit.E;
                        data = new KeyValuePair <int, int> [lit.C];

                        s.P = lit.O;
                        for (int i1 = 0; i1 < lit.C; i1++)
                        {
                            data[i1] = new KeyValuePair <int, int>(s.RI32E(), s.RI32E());
                        }
                    }