Пример #1
0
 public static Special[] getSpecialsFromFile(string[] fileLines)
 {
     string[][] fileLineData = LakiTool.C.Utils.CUtils.ParseFromStructInStruct(fileLines, "SpecialObjectPresets");
     Special[]  specialOut   = new Special[fileLineData.Length];
     for (int i = 0; i < specialOut.Length; i++)
     {
         specialOut[i]              = new Special();
         specialOut[i].preset_id    = (byte)MISCUtils.ParseInt(fileLineData[i][0]);
         specialOut[i].type         = SpecialUtil.getTypeFromName(fileLineData[i][1]);
         specialOut[i].defParam     = (byte)MISCUtils.ParseInt(fileLineData[i][2]);
         specialOut[i].modelName    = fileLineData[i][3];
         specialOut[i].behaviorName = fileLineData[i][4];
     }
     return(specialOut);
 }
Пример #2
0
        public static GCUtil[] GetDefinesFromFile(string[] fileLines)
        {
            List <GCUtil> gcs = new List <GCUtil>();

            string[] lineData;
            foreach (string line in fileLines)
            {
                lineData = MISCUtils.ParseAsmbd(line);
                if (lineData[0] == C.CConsts.def)
                {
                    gcs.Add(new GCUtil(lineData[1], MISCUtils.ParseInt(lineData[2])));
                    System.Windows.Forms.MessageBox.Show(gcs[gcs.Count - 1].name);
                }
            }

            return(gcs.ToArray());
        }
Пример #3
0
 public static SpecialObjectRenderStack getSpecialObjectsFromCollisionFile(string[] colData)
 {
     OBJs.Special.SpecialObjectRenderStack returnObj = new OBJs.Special.SpecialObjectRenderStack();
     string[] vals;
     foreach (string line in colData)
     {
         if (!(line.Contains("col") || line.Contains("special_object")))
         {
             continue;
         }
         vals = MISCUtils.ParseAsmbd(line);
         if (vals[0] == "special_object")
         {
             returnObj.addSpecialObject(vals[2], (short)MISCUtils.ParseInt(vals[4]), (short)MISCUtils.ParseInt(vals[5]), (short)MISCUtils.ParseInt(vals[6]));
         }
     }
     return(returnObj);
 }
Пример #4
0
 public static byte getPresetIdFromName(string[] fileLines, string modelName)
 {
     //todo change this with a sorta lut
     foreach (string line in fileLines)
     {
         string[] cont = MISCUtils.ParseAsmbd(line);
         if (cont.Length > 0)
         {
             if (cont[0] == ".set")
             {
                 if (cont[1] == modelName)
                 {
                     return((byte)MISCUtils.ParseInt(cont[2]));
                 }
             }
         }
     }
     return(0x00);
 }
Пример #5
0
        public static OBJs.CubeData getCubeDataFromF3DFile(string[] lines) //yeah sorry i make it check the whole file, just did this for convenience and also cause objects should be more accurately represented
        {
            CubeData data = new CubeData();

            string[] vs;
            if (lines == null)
            {
                return(data);
            }
            foreach (string line in lines)
            {
                vs = MISCUtils.ParseAsmbd(line);
                if (vs[0] == "vertex")
                {
                    data.updateCubeData((short)(MISCUtils.ParseInt(vs[1]) >> 4), (short)(MISCUtils.ParseInt(vs[2]) >> 4), (short)(MISCUtils.ParseInt(vs[3]) >> 4));
                }
            }
            return(data);
        }
Пример #6
0
        public void ParseColData()
        {
            int n = -1;

            string[] vals;
            Col      cold = new Col();

            foreach (string line in colData)
            {
                n++;
                if (!(line.Contains("col") || line.Contains("special_object")))
                {
                    continue;
                }
                vals = MISCUtils.ParseAsmbd(line);
                if (vals[0] == "colVertex")
                {
                    cold.colVertex((short)MISCUtils.ParseInt(vals[1]), (short)MISCUtils.ParseInt(vals[2]), (short)MISCUtils.ParseInt(vals[3]));
                }
                if (vals[0] == "colTri")
                {
                    cold.colTri((short)MISCUtils.ParseInt(vals[1]), (short)MISCUtils.ParseInt(vals[2]), (short)MISCUtils.ParseInt(vals[3]));
                }
                if (vals[0] == "colTriSpecial")
                {
                    cold.colTriSpecial((short)MISCUtils.ParseInt(vals[1]), (short)MISCUtils.ParseInt(vals[2]), (short)MISCUtils.ParseInt(vals[3]), (short)MISCUtils.ParseInt(vals[4]));
                }
                if (vals[0] == "colWaterBox")
                {
                    cold.colWaterBox((short)MISCUtils.ParseInt(vals[1]), (short)MISCUtils.ParseInt(vals[2]), (short)MISCUtils.ParseInt(vals[3]), (short)MISCUtils.ParseInt(vals[4]), (short)MISCUtils.ParseInt(vals[5]), (short)MISCUtils.ParseInt(vals[6]));
                }
                if (vals[0] == "colTriInit")
                {
                    cold.colTriInit(LakiTool.Col.Util.ColUtil.getCmdFromName(vals[1]), (short)MISCUtils.ParseInt(vals[2]));
                }
                if (vals[0] == "special_object")
                {
                    //stuff from here has been migrated to renderer and to objs and objs/special etc
                }
            }
        }
Пример #7
0
        private static List <GeoParam> getParamsFromLineData(string[] linedata)
        {
            List <GeoParam> geoparams = new List <GeoParam>();

            for (int i = 1; i < linedata.Length; i++)
            {
                dynamic paramdata;

                try
                {
                    paramdata = MISCUtils.ParseInt(linedata[i]);
                }
                catch
                {
                    paramdata = linedata[i];
                }

                geoparams.Add(new GeoParam(paramdata));
            }

            return(geoparams);
        }
Пример #8
0
        public static OBJFile.o getObjFromDL(LUTs inputData, string[] lines, int offset = 0, string objName = "default")
        {
            string[] vals;
            uint     vertSet = (uint)(vAdr == 0?1:0);

            OBJFile.o outObjFile = new OBJFile.o();
            outObjFile.oname = objName;
            uint lastVertAdr = OBJFileUtil.vAdr;
            int  n = -1;
            int  x = 0, y = 0;

            foreach (string line in lines)
            {
                n++;
                if (n < offset - 1)
                {
                    continue;
                }
                if (!(line.Contains("gsSP") || line.Contains("gsDP")))
                {
                    continue;
                }
                vals = MISCUtils.ParseAsmbd(line);
                if (vals[0] == "gsSPEndDisplayList" && offset > 0)
                {
                    break;
                }
                if (vals[0] == "gsSP1Triangle")
                {
                    uint v0 = (uint)MISCUtils.ParseInt(vals[1]);
                    uint v1 = (uint)MISCUtils.ParseInt(vals[2]);
                    uint v2 = (uint)MISCUtils.ParseInt(vals[3]);
                    v0 += lastVertAdr;
                    v1 += lastVertAdr;
                    v2 += lastVertAdr;
                    outObjFile.faces.Add(new OBJFile.f(new OBJFile.fFmt(v0, v0, v0), new OBJFile.fFmt(v1, v1, v1), new OBJFile.fFmt(v2, v2, v2)));
                }
                if (vals[0] == "gsSP2Triangles")
                {
                    uint v0 = (uint)MISCUtils.ParseInt(vals[1]);
                    uint v1 = (uint)MISCUtils.ParseInt(vals[2]);
                    uint v2 = (uint)MISCUtils.ParseInt(vals[3]);
                    v0 += lastVertAdr;
                    v1 += lastVertAdr;
                    v2 += lastVertAdr;
                    outObjFile.faces.Add(new OBJFile.f(new OBJFile.fFmt(v0, v0, v0), new OBJFile.fFmt(v1, v1, v1), new OBJFile.fFmt(v2, v2, v2)));
                    v0  = (uint)MISCUtils.ParseInt(vals[5]);
                    v1  = (uint)MISCUtils.ParseInt(vals[6]);
                    v2  = (uint)MISCUtils.ParseInt(vals[7]);
                    v0 += lastVertAdr;
                    v1 += lastVertAdr;
                    v2 += lastVertAdr;
                    outObjFile.faces.Add(new OBJFile.f(new OBJFile.fFmt(v0, v0, v0), new OBJFile.fFmt(v1, v1, v1), new OBJFile.fFmt(v2, v2, v2)));
                }
                if (vals[0] == "gsSPVertex")
                {
                    lastVertAdr += vertSet;
                    Vtx[] verteces = F3DUtils.getVtxFromName(vals[1], inputData.vtxLUT).ToArray();
                    for (int v = MISCUtils.ParseInt(vals[3]); v < MISCUtils.ParseInt(vals[2]) + MISCUtils.ParseInt(vals[3]); v++)
                    {
                        outObjFile.verts.Add(new OBJFile.v(verteces[v].X, verteces[v].Y, verteces[v].Z));
                        outObjFile.coords.Add(new OBJFile.vt(verteces[v].S, verteces[v].T, x, y));
                        outObjFile.normals.Add(new OBJFile.vn(verteces[v].R, verteces[v].G, verteces[v].B));
                    }
                    vertSet = (uint)MISCUtils.ParseInt(vals[2]);
                }
                if (vals[0] == "gsDPSetTextureImage")
                {
                    x = F3DUtils.getTexFromName(vals[4], inputData.texLUT).Size.Width;
                    y = F3DUtils.getTexFromName(vals[4], inputData.texLUT).Size.Height;
                }
            }
            OBJFileUtil.vAdr = lastVertAdr + vertSet;
            return(outObjFile);
        }