public void gsSP1Triangle(int v0, int v1, int v2, int flag) { F3DUtils.setUpVertColor(vtxbuffer[v0].R, vtxbuffer[v0].G, vtxbuffer[v0].B, vtxbuffer[v0].A, geommode); GL.TexCoord2((float)vtxbuffer[v0].S / 32 / x, (float)vtxbuffer[v0].T / 32 / y); GL.Vertex3(-vtxbuffer[v0].X >> 4, vtxbuffer[v0].Y >> 4, -vtxbuffer[v0].Z >> 4); F3DUtils.setUpVertColor(vtxbuffer[v1].R, vtxbuffer[v1].G, vtxbuffer[v1].B, vtxbuffer[v1].A, geommode); GL.TexCoord2((float)vtxbuffer[v1].S / 32 / x, (float)vtxbuffer[v1].T / 32 / y); GL.Vertex3(-vtxbuffer[v1].X >> 4, vtxbuffer[v1].Y >> 4, -vtxbuffer[v1].Z >> 4); F3DUtils.setUpVertColor(vtxbuffer[v2].R, vtxbuffer[v2].G, vtxbuffer[v2].B, vtxbuffer[v2].A, geommode); GL.TexCoord2((float)vtxbuffer[v2].S / 32 / x, (float)vtxbuffer[v2].T / 32 / y); GL.Vertex3(-vtxbuffer[v2].X >> 4, vtxbuffer[v2].Y >> 4, -vtxbuffer[v2].Z >> 4); }
public static void renderF3DFromFile(string filePath) { string[] contents = System.IO.File.ReadAllLines(filePath); LUTUtil lutmanager = new LUTUtil(); lutmanager.dldata = contents; lutmanager.curFile = filePath; lutmanager.fbpath = LakiTool.MISC.Game.gamePath; lutmanager.initF3D(); ParseF3D p = new ParseF3D(F3DUtils.getF3DCommandsFromLines(contents)); p.ParseDL(0, lutmanager.luts); }
public void gsDPSetTextureImage(Bitmap bitmap) { GL.End(); int id; BitmapData data = new BitmapData(); id = GL.GenTexture(); data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); GL.BindTexture(TextureTarget.Texture2D, id); x = data.Width; y = data.Height; GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0); bitmap.UnlockBits(data); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMinFilter.Linear); GL.BindTexture(TextureTarget.Texture2D, id); F3DUtils.setUpWrapST(wraps, wrapt); GL.Begin(BeginMode.Triangles); }
public void ParseDL(int offset, LUTs LUTc, SpecialRendering specialRendering = SpecialRendering.Off, List <GBI.Utils.LSUtil> labelsearchers = null, GBI.GBI GBIc = null) { if (GBIc == null) { GBIc = new GBI.GBI(); } GBI.F3DCommand dlelem; for (int n = offset; n < dldata.Count; n++) { dlelem = dldata[n]; switch (dlelem.Command) { case GBI.GBICommand.gsSPEndDisplayList: if (specialRendering == SpecialRendering.SEQ) { break; } return; case GBI.GBICommand.gsSPDisplayList: if (specialRendering == SpecialRendering.SEQ) { break; } ParseDL(F3DUtils.getIndexFromLabelSearchersAndName(labelsearchers, dlelem.Params[0].GetVal()), LUTc, SpecialRendering.Off, null, GBIc); break; case GBI.GBICommand.gsSP1Triangle: GBIc.gsSP1Triangle( dlelem.Params[0].GetVal(), dlelem.Params[1].GetVal(), dlelem.Params[2].GetVal(), dlelem.Params.Count > 3 ? dlelem.Params[3].GetVal() : 0 ); break; case GBI.GBICommand.gsSP2Triangles: GBIc.gsSP2Triangles( dlelem.Params[0].GetVal(), dlelem.Params[1].GetVal(), dlelem.Params[2].GetVal(), dlelem.Params[3].GetVal(), dlelem.Params[4].GetVal(), dlelem.Params[5].GetVal(), dlelem.Params[6].GetVal(), dlelem.Params.Count > 7 ? dlelem.Params[7].GetVal() : 0 ); break; case GBI.GBICommand.gsSPClearGeometryMode: GBIc.gsSPClearGeometryMode(F3DUtils.getGeomModeFromParams(dlelem.Params)); break; case GBI.GBICommand.gsSPSetGeometryMode: GBIc.gsSPSetGeometryMode(F3DUtils.getGeomModeFromParams(dlelem.Params)); break; case GBI.GBICommand.gsSPVertex: GBIc.gsSPVertex(F3DUtils.getVtxFromName(dlelem.Params[0].GetVal(), LUTc.vtxLUT).ToArray(), (byte)dlelem.Params[1].GetVal(), (byte)dlelem.Params[2].GetVal()); break; case GBI.GBICommand.gsSPLight: GBIc.gsSPLight(F3DUtils.getLightFromName(dlelem.Params[0].GetVal(), LUTc.lightLUT), (byte)dlelem.Params[1].GetVal()); break; case GBI.GBICommand.gsDPSetEnvColor: GBIc.gsDPSetEnvColor( (byte)dlelem.Params[0].GetVal(), //r (byte)dlelem.Params[1].GetVal(), //g (byte)dlelem.Params[2].GetVal(), //b (byte)dlelem.Params[3].GetVal() //a ); break; case GBI.GBICommand.gsDPSetTextureImage: GBIc.gsDPSetTextureImage(F3DUtils.getTexFromName(dlelem.Params[3].GetVal(), LUTc.texLUT)); break; case GBI.GBICommand.gsDPLoadTextureBlock: GBIc.gsDPSetTextureImage(F3DUtils.getTexFromName(dlelem.Params[0].GetVal(), LUTc.texLUT)); break; case GBI.GBICommand.gsDPSetTile: GBIc.gsDPSetTile(F3DUtils.getWarpSTFromParams(dlelem.Params)); break; } } }
public void ParseDL(int offset, GBI GBIc, LUTs LUTc) { int n = -1; foreach (string line in dldata) { n++; if (n < offset - 1) { continue; } if (!(line.Contains("gsSP") || line.Contains("gsDP"))) { continue; } vals = MISCUtils.ParseAsmbd(line); if (vals[0] == "gsSPEndDisplayList" && offset > 0) { return; } if (vals[0] == "gsSP1Triangle") { GBIc.gsSP1Triangle( MISCUtils.ParseInt(vals[1]), MISCUtils.ParseInt(vals[2]), MISCUtils.ParseInt(vals[3]), MISCUtils.ParseInt(vals[4]) ); } if (vals[0] == "gsSP2Triangles") { GBIc.gsSP2Triangles( MISCUtils.ParseInt(vals[1]), MISCUtils.ParseInt(vals[2]), MISCUtils.ParseInt(vals[3]), MISCUtils.ParseInt(vals[4]), MISCUtils.ParseInt(vals[5]), MISCUtils.ParseInt(vals[6]), MISCUtils.ParseInt(vals[7]), MISCUtils.ParseInt(vals[8]) ); } if (vals[0] == "gsSPClearGeometryMode") { GBIc.gsSPClearGeometryMode(F3DUtils.getGeomModeFromLineData(vals)); } if (vals[0] == "gsSPSetGeometryMode") { GBIc.gsSPSetGeometryMode(F3DUtils.getGeomModeFromLineData(vals)); } if (vals[0] == "gsSPVertex") { GBIc.gsSPVertex(F3DUtils.getVtxFromName(vals[1], LUTc.vtxLUT).ToArray(), (byte)MISCUtils.ParseInt(vals[2]), (byte)MISCUtils.ParseInt(vals[3])); } if (vals[0] == "gsSPLight") { GBIc.gsSPLight(F3DUtils.getLightFromName(vals[1], LUTc.lightLUT), (byte)MISCUtils.ParseInt(vals[2])); } if (vals[0] == "gsDPSetEnvColor") { GBIc.gsDPSetEnvColor( (byte)MISCUtils.ParseInt(vals[1]), //r (byte)MISCUtils.ParseInt(vals[2]), //g (byte)MISCUtils.ParseInt(vals[3]), //b (byte)MISCUtils.ParseInt(vals[4]) //a ); } if (vals[0] == "gsDPSetTextureImage") { GBIc.gsDPSetTextureImage(F3DUtils.getTexFromName(vals[4], LUTc.texLUT)); } if (vals[0] == "gsDPSetTile") { GBIc.gsDPSetTile(F3DUtils.getWarpSTFromLineData(vals)); } } }